From 2d28c447ec7a1e6c1826c85ccb0075994a66ea5c Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 24 Feb 2022 10:59:12 +1100 Subject: [PATCH] fix(db/rawExecute): Parse multiple returned rows --- fxmanifest.lua | 2 +- package.json | 2 +- src/database/rawExecute.ts | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index d64eb5a..0233203 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -3,7 +3,7 @@ game 'common' name 'oxmysql' description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.' -version '2.0.1' +version '2.0.2' url 'https://github.com/overextended/oxmysql' author 'overextended' diff --git a/package.json b/package.json index 0778b64..3c21e96 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oxmysql", - "version": "2.0.1", + "version": "2.0.2", "description": "FXServer to MySQL communication via node-mysql2", "repository": "git@github.com:overextended/oxmysql.git", "author": "dunak-debug <19434539+dunak-debug@users.noreply.github.com>", diff --git a/src/database/rawExecute.ts b/src/database/rawExecute.ts index d396443..a8e534f 100644 --- a/src/database/rawExecute.ts +++ b/src/database/rawExecute.ts @@ -31,7 +31,13 @@ export const rawExecute = async ( const executionTime = process.hrtime(); for (const params of parameters) { - results.push(parseResponse(type, (await connection.execute(query, params))[0])); + const [rows] = (await connection.execute(query, params)) as RowDataPacket[][]; + if (rows.length > 1) { + for (const row of rows) { + results.push(parseResponse(type, row)); + } + } else results.push(parseResponse(type, rows)); + logQuery(invokingResource, query, process.hrtime(executionTime)[1] / 1e6, params as typeof parameters); }