From dba490f22634f87d3af5a3a4c0866fc3095c9842 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Thu, 17 Oct 2024 18:14:41 +0200 Subject: [PATCH] fix(MySQL): routines do not return results, fixes #885 --- src/main/libs/clients/MySQLClient.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/libs/clients/MySQLClient.ts b/src/main/libs/clients/MySQLClient.ts index 6f99f19b..86072f69 100644 --- a/src/main/libs/clients/MySQLClient.ts +++ b/src/main/libs/clients/MySQLClient.ts @@ -1714,9 +1714,10 @@ export class MySQLClient extends BaseClient { connection.query({ sql: query, nestTables }).then(async ([response, fields]) => { timeStop = new Date(); const queryResult = response; + const fieldsArr = fields ? Array.isArray(fields[0]) ? fields[0] : fields : false;// Some times fields are nested in an array - let remappedFields = fields - ? fields.map(field => { + let remappedFields = fieldsArr + ? fieldsArr.map(field => { if (!field || Array.isArray(field)) return undefined; @@ -1785,7 +1786,7 @@ export class MySQLClient extends BaseClient { resolve({ duration: timeStop.getTime() - timeStart.getTime(), - rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? [] : queryResult : false, + rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? queryResult[0] : queryResult : false, report: !Array.isArray(queryResult) ? queryResult : false, fields: remappedFields, keys: keysArr