diff --git a/src/utils/index.ts b/src/utils/index.ts index f869013..44952a2 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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; diff --git a/test/utils/index.test.ts b/test/utils/index.test.ts index 1215835..3b69ff6 100644 --- a/test/utils/index.test.ts +++ b/test/utils/index.test.ts @@ -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); + }); });