Skip to content

Commit

Permalink
fix(db/rawExecute): Parse multiple returned rows
Browse files Browse the repository at this point in the history
  • Loading branch information
thelindat committed Feb 23, 2022
1 parent e29ca87 commit 2d28c44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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>",
Expand Down
8 changes: 7 additions & 1 deletion src/database/rawExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 2d28c44

Please sign in to comment.