Skip to content

Commit

Permalink
fix: Resolve error when parameter length does not match
Browse files Browse the repository at this point in the history
- Throws a more specific error when receiving mismatch for column and value counts

- Resolves error when final parameter is nil
  • Loading branch information
thelindat committed Oct 15, 2021
1 parent 22de50c commit 30a3910
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ const parseParameters = (query, parameters) => {

if (Array.isArray(parameters)) {
if (parameters.length === 0) return [query, [null]];
if (parameters.length !== queryParams.length) {
throw new Error(`Undefined query parameter #${parameters.length + 1}`, query, parameters);
const diff = queryParams.length - parameters.length
if (diff > 0) {
for (let i=0; i < diff; i++) {
parameters[queryParams.length+i] = null
}
}
} else {
let arr = [];
Expand Down

0 comments on commit 30a3910

Please sign in to comment.