fix: clean sql white spaces #21

This commit is contained in:
Ziv 2021-05-11 13:39:42 +08:00 committed by GitHub
parent bff1618742
commit dc49697302
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -163,7 +163,7 @@ function splitSql(sql: string) {
* @param {String} sql
*/
function cleanSql(sql: string) {
sql.trim(); // 删除前后空格
sql = sql.trim(); // 删除前后空格
const tokens = lexer(sql);
let resultSql = '';
let startIndex = 0;

View File

@ -39,4 +39,12 @@ describe('utils', () => {
const result = cleanSql(sql);
expect(result.indexOf('xxx')).toEqual(-1);
});
test('clean SQL white spaces', () => {
const sql = `
select * from a; `;
const expected = 'select * from a;';
const result = cleanSql(sql);
expect(result).toEqual(expected);
});
});