From af053b61fc373bdc63dd3801209e57d4b338a4b6 Mon Sep 17 00:00:00 2001 From: mechanarchy <1166756+mechanarchy@users.noreply.github.com> Date: Sat, 17 Jun 2023 17:06:17 +1000 Subject: [PATCH] Ignore SQL comments in query console --- src/routes/api/sql.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/routes/api/sql.js b/src/routes/api/sql.js index 1c853f365..f37b6d310 100644 --- a/src/routes/api/sql.js +++ b/src/routes/api/sql.js @@ -36,6 +36,11 @@ function execute(req) { 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) + } if (query.toLowerCase().startsWith('select') || query.toLowerCase().startsWith('with')) { results.push(sql.getRows(query));