1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 17:59:25 +00:00

Fix bug where trailing whitespace in sql query after ; would error

This commit is contained in:
2022-01-20 17:57:01 +00:00
parent 5854c3928a
commit ec3890fa7f
3 changed files with 17 additions and 2 deletions

View File

@@ -46,8 +46,10 @@ class DatabaseConnectionPool {
* @return {(Array<object>|object)} Data returned from the database
*/
async runQuery(sql, params) {
sql = sql.trim();
if (sql.slice(-1) !== ';')
throw new Error('Invalid query, needs ;');
throw new Error('Invalid query, needs trailing ;');
// Execute as non-prepared if no params are supplied
if (typeof params === 'undefined') {