fix: clean sql white spaces #21
This commit is contained in:
parent
bff1618742
commit
dc49697302
@ -163,7 +163,7 @@ function splitSql(sql: string) {
|
|||||||
* @param {String} sql
|
* @param {String} sql
|
||||||
*/
|
*/
|
||||||
function cleanSql(sql: string) {
|
function cleanSql(sql: string) {
|
||||||
sql.trim(); // 删除前后空格
|
sql = sql.trim(); // 删除前后空格
|
||||||
const tokens = lexer(sql);
|
const tokens = lexer(sql);
|
||||||
let resultSql = '';
|
let resultSql = '';
|
||||||
let startIndex = 0;
|
let startIndex = 0;
|
||||||
|
@ -39,4 +39,12 @@ describe('utils', () => {
|
|||||||
const result = cleanSql(sql);
|
const result = cleanSql(sql);
|
||||||
expect(result.indexOf('xxx')).toEqual(-1);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user