22 lines
770 B
TypeScript
22 lines
770 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { formatCalciteSql } from './dataspace-sql';
|
|
|
|
describe('formatCalciteSql', () => {
|
|
it('formats common Calcite query clauses', () => {
|
|
expect(
|
|
formatCalciteSql(
|
|
'select o.id, c.name from MYSQL_1.MAIN.outlet o join PG_2.PUBLIC.customer c on c.id=o.id where o.name is not null order by o.id desc limit 100',
|
|
),
|
|
).toBe(
|
|
'SELECT o.id, c.name\nFROM MYSQL_1.MAIN.outlet o\nJOIN PG_2.PUBLIC.customer c ON c.id=o.id\nWHERE o.name is not null\nORDER BY o.id DESC\nLIMIT 100;\n',
|
|
);
|
|
});
|
|
|
|
it('preserves quoted keyword literals', () => {
|
|
expect(formatCalciteSql("select 'from where' as label from demo")).toBe(
|
|
"SELECT 'from where' AS label\nFROM demo;\n",
|
|
);
|
|
});
|
|
});
|