dbgate-query-splitter
Advanced tools
Comparing version 4.10.1 to 4.10.2
@@ -40,13 +40,2 @@ "use strict"; | ||
} | ||
function isStringEnd(s, pos, endch, escapech) { | ||
if (!escapech) { | ||
return s[pos] == endch; | ||
} | ||
if (endch == escapech) { | ||
return s[pos] == endch && s[pos + 1] != endch; | ||
} | ||
else { | ||
return s[pos] == endch && s[pos - 1] != escapech; | ||
} | ||
} | ||
const WHITESPACE_TOKEN = { | ||
@@ -93,4 +82,7 @@ type: 'whitespace', | ||
const escapech = context.options.stringEscapes[ch]; | ||
while (pos < context.end && !isStringEnd(s, pos, endch, escapech)) { | ||
if (endch == escapech && s[pos] == endch && s[pos + 1] == endch) { | ||
while (pos < context.end) { | ||
if (s[pos] == endch) { | ||
break; | ||
} | ||
if (escapech && s[pos] == escapech) { | ||
pos += 2; | ||
@@ -97,0 +89,0 @@ } |
@@ -17,2 +17,10 @@ "use strict"; | ||
}); | ||
test('correct split 2 queries - with escaped string', () => { | ||
const output = (0, splitQuery_1.splitQuery)("INSERT INTO names (name) VALUES('one\\\\');INSERT INTO names (name) VALUES('two\\\\');", options_1.mysqlSplitterOptions); | ||
expect(output).toEqual(["INSERT INTO names (name) VALUES('one\\\\')", "INSERT INTO names (name) VALUES('two\\\\')"]); | ||
}); | ||
test('incorrect used escape', () => { | ||
const output = (0, splitQuery_1.splitQuery)("query1\\", options_1.mysqlSplitterOptions); | ||
expect(output).toEqual(["query1\\"]); | ||
}); | ||
test('delete empty query', () => { | ||
@@ -19,0 +27,0 @@ const output = (0, splitQuery_1.splitQuery)(';;;\n;;SELECT * FROM `table1`;;;;;SELECT * FROM `table2`;;; ;;;', options_1.mysqlSplitterOptions); |
{ | ||
"version": "4.10.1", | ||
"version": "4.10.2", | ||
"name": "dbgate-query-splitter", | ||
@@ -4,0 +4,0 @@ "main": "lib/index.js", |
43317