Skip to content

Fix wrong arg count in Exec's "not enough args" error#1398

Open
c-tonneslan wants to merge 1 commit into
mattn:masterfrom
c-tonneslan:fix/exec-not-enough-args-count
Open

Fix wrong arg count in Exec's "not enough args" error#1398
c-tonneslan wants to merge 1 commit into
mattn:masterfrom
c-tonneslan:fix/exec-not-enough-args-count

Conversation

@c-tonneslan
Copy link
Copy Markdown

Closes #1395

Exec and Query share the same multi-statement loop and trip the same len(args)-start < na check, but the error messages disagree on the second number. With one arg passed to SELECT ?; SELECT ?:

exec  -> not enough args to execute query: want 1 got 1
query -> not enough args to execute query: want 1 got 0

The Query path was already right (args remaining after the first statement consumed one), Exec was printing the total args originally passed in. This just brings Exec in line.

Added a regression test that asserts both paths produce the same message.

The Exec and Query paths share the same multi-statement loop and the
same `len(args)-start < na` check, but the Exec error message was
printing `len(args)` instead of `len(args)-start`. With one arg passed
to a two-statement query like `SELECT ?; SELECT ?`, the first statement
consumes the arg and the second one trips the check, so the "got" count
should be 0 (args remaining), not 1 (total args originally passed).

The Query path was already correct. This just brings Exec in line.

Closes mattn#1395

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exec returns wrong arg count in "not enough args" error

1 participant