mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-03 22:20:56 +00:00
fix(execute): incorrect response parsing
Fixes several regressions and issues from ef0dfaa.
Sending a single parameter would set 'single' to true, ignoring multiple
results from the database and returning 'null'.
SELECT should not trigger transactions, not the other way around.
Results should not be parsed when no callback is defined.
This commit is contained in:
1 parent
9511af734b
commit
fa1cdcc668
3 files changed
+7
-8
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ game 'common'
|
|||||||
|
|
||||||
name 'oxmysql'
|
name 'oxmysql'
|
||||||
description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.'
|
description 'Database wrapper for FiveM utilising node-mysql2 offering improved performance and security.'
|
||||||
version '2.2.3'
|
version '2.2.4'
|
||||||
url 'https://github.com/overextended/oxmysql'
|
url 'https://github.com/overextended/oxmysql'
|
||||||
author 'overextended'
|
author 'overextended'
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "oxmysql",
|
"name": "oxmysql",
|
||||||
"version": "2.2.3",
|
"version": "2.2.4",
|
||||||
"description": "FXServer to MySQL communication via node-mysql2",
|
"description": "FXServer to MySQL communication via node-mysql2",
|
||||||
"repository": "[email protected]:overextended/oxmysql.git",
|
"repository": "[email protected]:overextended/oxmysql.git",
|
||||||
"author": "dunak-debug <[email protected]>",
|
"author": "dunak-debug <[email protected]>",
|
||||||
|
|||||||
@@ -14,13 +14,9 @@ export const rawExecute = async (
|
|||||||
) => {
|
) => {
|
||||||
const type = executeType(query);
|
const type = executeType(query);
|
||||||
parameters = parseExecute(parameters);
|
parameters = parseExecute(parameters);
|
||||||
|
|
||||||
let single: boolean;
|
let single: boolean;
|
||||||
|
|
||||||
if (!parameters.every(Array.isArray)) {
|
if (!parameters.every(Array.isArray)) parameters = [[...parameters]];
|
||||||
single = true;
|
|
||||||
parameters = [[...parameters]];
|
|
||||||
}
|
|
||||||
|
|
||||||
const length = parameters.length - 1;
|
const length = parameters.length - 1;
|
||||||
|
|
||||||
@@ -41,15 +37,18 @@ export const rawExecute = async (
|
|||||||
connection.execute(query, values, (err, results: RowDataPacket[][]) => {
|
connection.execute(query, values, (err, results: RowDataPacket[][]) => {
|
||||||
if (err) return reject([connection, err]);
|
if (err) return reject([connection, err]);
|
||||||
|
|
||||||
|
if (cb) {
|
||||||
if (results.length > 1) {
|
if (results.length > 1) {
|
||||||
for (const value of results) {
|
for (const value of results) {
|
||||||
response.push(parseResponse(type, value));
|
response.push(parseResponse(type, value));
|
||||||
}
|
}
|
||||||
} else response.push(parseResponse(type, results));
|
} else response.push(parseResponse(type, results));
|
||||||
|
}
|
||||||
|
|
||||||
logQuery(invokingResource, query, process.hrtime(executionTime)[1] / 1e6, values as typeof parameters);
|
logQuery(invokingResource, query, process.hrtime(executionTime)[1] / 1e6, values as typeof parameters);
|
||||||
|
|
||||||
if (index === length) {
|
if (index === length) {
|
||||||
|
single = response.length === 1;
|
||||||
if (!single && type !== null) connection.commit();
|
if (!single && type !== null) connection.commit();
|
||||||
connection.release();
|
connection.release();
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ export const rawExecute = async (
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (single || type !== null) {
|
if (type === null) {
|
||||||
execute();
|
execute();
|
||||||
} else
|
} else
|
||||||
connection.beginTransaction((err) => {
|
connection.beginTransaction((err) => {
|
||||||
|
|||||||
Reference in new issue
Block a user