|
|
@ -1630,8 +1630,36 @@ class SqliteClient extends KnexClient { |
|
|
|
|
|
|
|
|
|
|
|
const trx = await this.sqlClient.transaction(); |
|
|
|
const trx = await this.sqlClient.transaction(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const splitQueries = (query) => { |
|
|
|
|
|
|
|
const queries = []; |
|
|
|
|
|
|
|
let quotationCount = 0; |
|
|
|
|
|
|
|
let currentQuery = ''; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < query.length; i++) { |
|
|
|
|
|
|
|
if (query[i] === '"' || query[i] === "'") { |
|
|
|
|
|
|
|
// Ignore if quotation is escaped
|
|
|
|
|
|
|
|
if (i > 0 && query[i - 1] !== '\\') { |
|
|
|
|
|
|
|
quotationCount++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (query[i] === ';' && quotationCount % 2 === 0) { |
|
|
|
|
|
|
|
queries.push(currentQuery); |
|
|
|
|
|
|
|
currentQuery = ''; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
currentQuery += query[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentQuery.trim() !== '') { |
|
|
|
|
|
|
|
queries.push(currentQuery); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return queries; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
const queries = upQuery.split(';'); |
|
|
|
const queries = splitQueries(upQuery); |
|
|
|
for (let i = 0; i < queries.length; i++) { |
|
|
|
for (let i = 0; i < queries.length; i++) { |
|
|
|
if (queries[i].trim() !== '') { |
|
|
|
if (queries[i].trim() !== '') { |
|
|
|
await trx.raw(queries[i]); |
|
|
|
await trx.raw(queries[i]); |
|
|
|