mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 22:22:50 +00:00
fix: Assign object entries to array
Assigning the entries to an array first permits comparing the lengths and setting undefined entries as null
This commit is contained in:
1 parent
30a391031b
commit
4646c6f027
1 file changed
+9
-8
+9
-8
@@ -36,6 +36,14 @@ const parseParameters = (query, parameters) => {
|
||||
if (parameters === undefined)
|
||||
throw new FormatError(`Placeholders were defined, but query received no parameters!`, query);
|
||||
|
||||
if (!Array.isArray(parameters)) {
|
||||
let arr = [];
|
||||
Object.entries(parameters).forEach((entry) => {
|
||||
const [key, value] = entry;
|
||||
arr[key - 1] = value;
|
||||
});
|
||||
parameters = arr
|
||||
}
|
||||
if (Array.isArray(parameters)) {
|
||||
if (parameters.length === 0) return [query, [null]];
|
||||
const diff = queryParams.length - parameters.length
|
||||
@@ -44,14 +52,7 @@ const parseParameters = (query, parameters) => {
|
||||
parameters[queryParams.length+i] = null
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let arr = [];
|
||||
Object.entries(parameters).forEach((entry) => {
|
||||
const [key, value] = entry;
|
||||
arr[key - 1] = value;
|
||||
});
|
||||
return [query, arr];
|
||||
}
|
||||
}
|
||||
|
||||
return [query, parameters];
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user