Skip to content

Commit

Permalink
fix: clea sql white spaces \n fix #21
Browse files Browse the repository at this point in the history
  • Loading branch information
wewoor committed May 11, 2021
1 parent 3fbb1b3 commit c362801
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions test/utils/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit c362801

Please sign in to comment.