mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-05 22:03:36 +08:00
- 统一 PG-like 数据源字段和索引元数据查询,支持 search_path 可见表 - 兼容 snake_case、布尔别名和字符串唯一索引标记 - 修复 DuckDB main/memory 路径解析,避免误判外部 catalog - 补充前后端回归测试,覆盖可编辑结果定位和元数据重试路径
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
getColumnDefinitionComment,
|
|
getColumnDefinitionKey,
|
|
getColumnDefinitionName,
|
|
getColumnDefinitionType,
|
|
normalizeColumnDefinition,
|
|
} from './columnDefinition';
|
|
|
|
describe('columnDefinition metadata normalization', () => {
|
|
it('reads Go/Wails style column metadata fields', () => {
|
|
const column = { Name: 'UPDATED_AT', Type: 'TIMESTAMP', Key: 'PRI', Comment: '更新时间' };
|
|
|
|
expect(getColumnDefinitionName(column)).toBe('UPDATED_AT');
|
|
expect(getColumnDefinitionType(column)).toBe('TIMESTAMP');
|
|
expect(getColumnDefinitionKey(column)).toBe('PRI');
|
|
expect(getColumnDefinitionComment(column)).toBe('更新时间');
|
|
});
|
|
|
|
it('reads Oracle dictionary style column metadata aliases', () => {
|
|
const column = { COLUMN_NAME: 'UPDATED_AT', DATA_TYPE: 'TIMESTAMP', COLUMN_KEY: 'PRI', COMMENTS: '更新时间' };
|
|
|
|
expect(normalizeColumnDefinition(column)).toMatchObject({
|
|
name: 'UPDATED_AT',
|
|
type: 'TIMESTAMP',
|
|
key: 'PRI',
|
|
comment: '更新时间',
|
|
});
|
|
});
|
|
|
|
it('maps boolean primary and unique metadata aliases to GoNavi keys', () => {
|
|
expect(getColumnDefinitionKey({ column_name: 'id', isPrimary: true })).toBe('PRI');
|
|
expect(getColumnDefinitionKey({ column_name: 'id', primary_key: 't' })).toBe('PRI');
|
|
expect(getColumnDefinitionKey({ column_name: 'email', is_unique: 'yes' })).toBe('UNI');
|
|
expect(getColumnDefinitionKey({ column_name: 'id', column_key: 'primary key' })).toBe('PRI');
|
|
});
|
|
});
|