Files
MyGoNavi/frontend/src/utils/ddlFormat.test.ts
Syngnat a5b27820cb feat(ddl): 为 DDL 视图增加按方言格式化展示能力
- 新增通用 DDL 格式化工具
- DataGrid 查看 DDL 时按数据源方言输出可读 SQL
- 覆盖 DuckDB DDL 展示与工具层测试
2026-06-05 22:21:40 +08:00

23 lines
866 B
TypeScript

import { describe, expect, it } from 'vitest';
import { formatDdlForDisplay } from './ddlFormat';
describe('formatDdlForDisplay', () => {
it('formats DuckDB create table SQL into multiline output', () => {
const raw = 'CREATE TABLE customers(customer_id BIGINT, customer_code VARCHAR, city VARCHAR, tier VARCHAR, signup_date DATE, lifetime_value DECIMAL(12,2), PRIMARY KEY(customer_id));';
const formatted = formatDdlForDisplay(raw, 'duckdb');
expect(formatted).toContain('CREATE TABLE customers (');
expect(formatted).toContain('customer_id BIGINT,');
expect(formatted).toContain('PRIMARY KEY (customer_id)');
expect(formatted).toContain('\n');
});
it('returns original text when formatter cannot parse the statement', () => {
const raw = 'not valid ddl(';
expect(formatDdlForDisplay(raw, 'duckdb')).toBe(raw);
});
});