parser: optionally rewrite numbered params to positional params #306
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.
JDBC seems to only support positional parameters like
?
. I had to write a HACK to convert numbered parameters like $1
to?
. This is buggy and terrible. It also means that you can't use$1
multiple times in the same query to reference the same value.This is a better change that examines the AST and edits the parser in the parsing step. It's cherry-picked from mightyguava#5 because I'd like to merge changes to core parsing code to master rather than risk complicated merge conflicts later.
When the option is off, nothing changes.
When the option is on, the parameters are no longer sorted by their
Number
, since we will rely on position as the binding index instead. Repeated parameters are no longer ignored. All parameters are included in the same order they appear in the query string. This means that there may be multipleColumns
for the same query with the sameNumber
. The generator can choose to de-dupe or not. Since this option will be tied to the generator, likely only Java/Kotlin generators, this is fine.