Repository navigation
fix(sqlite): convert bound parameters with --bind and bindings - #348
Merged
Merged
Conversation
Bound values are written in place of their markers as typed DuckDB literals, so the output runs as it is, for one statement or a script. Each value must be one SQLite literal; a marker with no value and a value no statement names refuse.
…th readings of ?N
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
sqlbabel convert --dialect sqliterefused every statement with a parameter marker (?,?N,:name,@name,$name), because nothing could bind values to it. The converter already types a bound parameter by its value's storage class for the evidence replay; the command line and Python had no way to pass values.Changes
convert --bind MARKER=LITERAL(repeatable) andConvertOptions.bindingsin Python. Each marker becomes its value's typed DuckDB literal (CAST(7 AS BIGINT),CAST('x' AS VARCHAR), real and blob literals,NULL), so the output runs as it is, specialised to those values.NULL) are refused.--bindwith another dialect exits 2.--bind,?Nbinds only a?/?Nmarker; a name binds by its name. A view naming a parameter is refused, as SQLite refuses it.PREPARE/EXECUTEwith$n) is unchanged.Verification
convert(bindings=)withconvert --bindand run a?SELECT, a?NINSERT then UPDATE … RETURNING and a:nameINSERT … RETURNING on DuckDB against Python sqlite3's rows and types.make check-cipasses on the head.