lava-oushudb-dt-sql-parser/test/parser/mysql/syntax/dml.test.ts
Hayden 3c7c59fb70
feat: optimize suggestion (#231)
* feat: optimize the strategy of finding the right range

* test: apply commentOtherLine util to all suggestion tests

* test: decomment suggestion test cases

* test: add suggestion test cases in multiple statements

* chore: improve comments

* test: update log info in test
2023-12-13 11:33:47 +08:00

43 lines
1.6 KiB
TypeScript

import MySQL from '../../../../src/parser/mysql';
import { readSQL } from '../../../helper';
const parser = new MySQL();
const features = {
call: readSQL(__dirname, 'call.sql'),
delete: readSQL(__dirname, 'delete.sql'),
do: readSQL(__dirname, 'do.sql'),
handler: readSQL(__dirname, 'handler.sql'),
importTable: readSQL(__dirname, 'importTable.sql'),
insert: readSQL(__dirname, 'insert.sql'),
insertSelect: readSQL(__dirname, 'insertSelect.sql'),
interSect: readSQL(__dirname, 'interSect.sql'),
loadData: readSQL(__dirname, 'loadData.sql'),
loadXml: readSQL(__dirname, 'loadXml.sql'),
parenthesizedQuery: readSQL(__dirname, 'parenthesizedQuery.sql'),
replace: readSQL(__dirname, 'replace.sql'),
select: readSQL(__dirname, 'select.sql'),
selectJoin: readSQL(__dirname, 'selectJoin.sql'),
setOperations: readSQL(__dirname, 'setOperations.sql'),
subQueries: readSQL(__dirname, 'subQueries.sql'),
table: readSQL(__dirname, 'table.sql'),
update: readSQL(__dirname, 'update.sql'),
union: readSQL(__dirname, 'union.sql'),
values: readSQL(__dirname, 'values.sql'),
with: readSQL(__dirname, 'with.sql'),
};
describe('MySQL DML Syntax Tests', () => {
Object.keys(features).forEach((key) => {
features[key].forEach((sql) => {
it(sql, () => {
const result = parser.validate(sql);
if (result.length) {
console.log(result, `\nPlease check sql: ${sql}`);
}
expect(result.length).toBe(0);
});
});
});
});