parser: optionally rewrite numbered params to positional params#306
Closed
mightyguava wants to merge 1 commit intosqlc-dev:masterfrom
Closed
parser: optionally rewrite numbered params to positional params#306mightyguava wants to merge 1 commit intosqlc-dev:masterfrom
mightyguava wants to merge 1 commit intosqlc-dev:masterfrom
Conversation
mightyguava
commented
Jan 28, 2020
| parent nodes.Node | ||
| rangeVar *nodes.RangeVar | ||
| refs map[int]paramRef | ||
| refs *[]paramRef |
Contributor
Author
There was a problem hiding this comment.
So I tried to make Visit take a pointer receiver: (p *paramSearch), rather than doing a pointer to a slice here. This broke the DeleteVenue query parsing somehow. The parent for the second parameter became a FunctionCall instead of an Expr. I'm a compilers noob so I decided to not dive down that rabbit hole.
| EmitJSONTags bool `json:"emit_json_tags"` | ||
| EmitPreparedQueries bool `json:"emit_prepared_queries"` | ||
| Overrides []Override `json:"overrides"` | ||
| // HACK: this is only set in tests, only here till Kotlin support can be merged. |
Contributor
Author
There was a problem hiding this comment.
I promise to remove this when Kolint support is merged :)
This was referenced Jan 28, 2020
Merged
Contributor
Author
|
@kyleconroy what do you think about merging this PR? I split it out of the kotlin branch as it's in the parser code and I'm nervous about it running into more merge conflicts (it already has). |
Collaborator
|
I believe this can be closed now that the Kotlin branch has been merged. |
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.
JDBC seems to only support positional parameters like
?. I had to write a HACK to convert numbered parameters like $1to?. This is buggy and terrible. It also means that you can't use$1multiple 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 multipleColumnsfor 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.