feat(parser): support '?' positional placeholders (fix #522) - #533
Open
basili4-1982 wants to merge 1 commit into
Open
feat(parser): support '?' positional placeholders (fix #522)#533basili4-1982 wants to merge 1 commit into
basili4-1982 wants to merge 1 commit into
Conversation
Treat a bare '?' at operand position as a placeholder alongside `$1` / @PARAM. Previously `WHERE a = ?` failed with 'unexpected token: QUESTION'. The PostgreSQL JSON key-existence operator (data ? 'key') is unchanged: it is parsed in binary-operator position, so an operand-position '?' is unambiguous. Regression: TestQuestionPlaceholder + TestQuestionJSONOperatorStillWorks.
|
@basili4-1982 is attempting to deploy a commit to the coolajitpratapsingh0-9932's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Support JDBC
?positional placeholders so that parameterized queries parse andround-trip. Currently
WHERE a = ?fails withunexpected token: QUESTION(issue #522).Root cause
The tokenizer already emits
TokenTypeQuestionfor?, but the parser treatedit only as the PostgreSQL JSON key-existence operator (binary-operator position)
and rejected an operand-position
?.Changes
pkg/sql/parser/expressions_literal.go: a bare?at operand position isparsed as a placeholder alongside
$1/@param.pkg/sql/parser/question_placeholder_test.go: regression tests,including a guard that PostgreSQL JSON
data ? 'key'still parses.The JSON operator is unaffected: it is parsed in binary-operator position, so an
operand-position
?is unambiguous.Test plan
TestQuestionPlaceholder(single / multiple / with GROUP BY) passTestQuestionJSONOperatorStillWorkspass (Postgres dialect)go test -short ./pkg/sql/ast/ ./pkg/sql/parser/ ./pkg/gosqlx/ ./pkg/formatter/ ./pkg/transform/greenCloses #522.