Fix SQL comment handling

This commit is contained in:
mechanarchy 2023-06-23 09:06:14 +10:00 committed by GitHub
parent af053b61fc
commit 1fc23c948e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,13 +33,14 @@ function execute(req) {
for (let query of queries) {
query = query.trim();
if (!query) {
continue;
}
while (query.startsWith('-- ') {
// Query starts with one or more SQL comments, discard these before we execute.
query = query.substr(query.indexOf('\n') + 1)
const pivot = query.indexOf('\n');
query = pivot > 0 ? query.substr(pivot + 1).trim() : "";
}
if (!query) {
continue;
}
if (query.toLowerCase().startsWith('select') || query.toLowerCase().startsWith('with')) {