From 0817515b1016001e07c0ae74ffb1e2a52771658f Mon Sep 17 00:00:00 2001 From: Antonino Natale Date: Tue, 10 Dec 2024 21:59:41 +0100 Subject: [PATCH] fix: handle empty result set by rejecting with an error on mysql query --- server/util-server.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/util-server.js b/server/util-server.js index 5ebc62ac5..ceb702e12 100644 --- a/server/util-server.js +++ b/server/util-server.js @@ -421,7 +421,11 @@ exports.mysqlQuery = function (connectionString, query, password = undefined) { reject(err); } else { if (Array.isArray(res)) { - resolve("Rows: " + res.length); + if (res.length === 0) { + reject(new Error("No rows returned")); + } else { + resolve("Rows: " + res.length); + } } else { resolve("No Error, but the result is not an array. Type: " + typeof res); }