Skip to content

feat(parser): support '?' positional placeholders (fix #522) - #533

Open
basili4-1982 wants to merge 1 commit into
ajitpratap0:mainfrom
basili4-1982:feat/question-placeholders
Open

feat(parser): support '?' positional placeholders (fix #522)#533
basili4-1982 wants to merge 1 commit into
ajitpratap0:mainfrom
basili4-1982:feat/question-placeholders

Conversation

@basili4-1982

Copy link
Copy Markdown

Summary

Support JDBC ? positional placeholders so that parameterized queries parse and
round-trip. Currently WHERE a = ? fails with unexpected token: QUESTION (issue #522).

Root cause

The tokenizer already emits TokenTypeQuestion for ?, but the parser treated
it 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 is
    parsed 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) pass
  • TestQuestionJSONOperatorStillWorks pass (Postgres dialect)
  • go test -short ./pkg/sql/ast/ ./pkg/sql/parser/ ./pkg/gosqlx/ ./pkg/formatter/ ./pkg/transform/ green

Closes #522.

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.
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support for question marks (?) as parameter placeholders

1 participant