From b3100d2653e3c0b2d9ebec5768390676f666dedb Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 4 May 2023 09:55:36 +0200 Subject: [PATCH] refs #5595 remove OkPackets from logIn and logOut --- loopback/common/models/vn-model.js | 2 +- loopback/server/connectors/vn-mysql.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 992598fb5..1cb389099 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -197,7 +197,7 @@ module.exports = function(Self) { * Shortcut to VnMySQL.executeP() */ rawSql(query, params, options, cb) { - const userId = options.userId; + const userId = options?.userId; if (userId) { params.unshift(userId); return this.dataSource.connector.executeP( diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 40ad78bde..9ba65d517 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -17,6 +17,12 @@ class VnMySQL extends MySQL { executeP(query, params, options = {}, cb) { return new Promise((resolve, reject) => { this.execute(query, params, options, (error, response) => { + if(options?.userId) + { + response.shift(); // Remove OkPacket from logIn + response.pop(); // Remove OkPacket from logOut + response = response[response.length - 1] // Keep only query response + } if (cb) cb(error, response); if (error)