2023-05-04 10:13:05 +08:00
|
|
|
import GenericSQL from '../../../src/parser/generic';
|
2020-09-11 17:39:10 +08:00
|
|
|
|
|
|
|
describe('Generic SQL Syntax Tests', () => {
|
2021-01-05 17:41:21 +08:00
|
|
|
const parser = new GenericSQL();
|
2020-09-11 17:39:10 +08:00
|
|
|
|
|
|
|
test('Select Statement', () => {
|
|
|
|
const sql = 'select id,name from user1;';
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Select 1+1', () => {
|
|
|
|
const sql = 'SELECT 1+1;';
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
2023-01-09 11:01:10 +08:00
|
|
|
|
|
|
|
test('Test invalid Double Line Comment statement', () => {
|
|
|
|
let sql = `-test comment\n`;
|
|
|
|
let result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Test valid Double Line Comment statement', () => {
|
|
|
|
const sql = `----test comment\n`;
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Test valid Hash Sign Line Comment statement', () => {
|
|
|
|
const sql = `#test comment\n`;
|
|
|
|
const result = parser.validate(sql);
|
|
|
|
expect(result.length).toBe(0);
|
|
|
|
});
|
2020-09-11 17:39:10 +08:00
|
|
|
});
|