fix(execute): handle nil values in nested arrays

Lua tables are msgpacked with the "without_hole" setting.
Nested tables being sent with "prepare" failed to account for
nil values in tables unpacking into objects.
This commit is contained in:
Linden committed 2022-11-08 15:17:01 +11:00
1 parent b5190f98e9
commit 25f8feb793
2 files changed
+25 -7

No files matched your search

+2 -6
View File
@@ -14,11 +14,10 @@ export const rawExecute = async (
throwError?: boolean
) => {
const type = executeType(query);
parameters = parseExecute(parameters);
const placeholders = query.split('?').length - 1;
parameters = parseExecute(placeholders, parameters);
let response = [] as any;
if (!parameters.every(Array.isArray)) parameters = [[...parameters]];
await scheduleTick();
return await new Promise((resolve, reject) => {
@@ -26,11 +25,8 @@ export const rawExecute = async (
if (err) return reject(err.message);
if (parameters.length === 0) return reject(`Query received no parameters.`);
const placeholders = query.split('?').length - 1;
parameters.forEach((values, index) => {
const executionTime = process.hrtime();
values = parseValues(placeholders, values);
connection.execute(query, values, (err, results: RowDataPacket[][]) => {
if (err) {