2025-04-01 10:38:02 +09:00

19 lines
538 B
TypeScript

import { SQLQuery, QueryEditorExpressionType } from '@grafana/sql';
import { toRawSql } from './sqlUtil';
describe('toRawSql should escape database names', () => {
const query: SQLQuery = {
dataset: 'foo',
sql: {
columns: [{ name: 'a', alias: 'lol', type: QueryEditorExpressionType.Function }],
},
refId: 'lolsob',
table: 'table',
};
const queryString = toRawSql(query);
it('should escapte database names', () => {
expect(queryString).toContain(`FROM [${query.dataset}].${query.table}`);
});
});