Skip to content

fix: handle named parameters in identifier contexts - #790

Open
edjubert wants to merge 6 commits into
supabase-community:mainfrom
edjubert:edjubert/named-parameter-contexts
Open

fix: handle named parameters in identifier contexts#790
edjubert wants to merge 6 commits into
supabase-community:mainfrom
edjubert:edjubert/named-parameter-contexts

Conversation

@edjubert

@edjubert edjubert commented Sep 10, 2026

Copy link
Copy Markdown

What kind of change does this PR introduce?

Bug fix.

What is the current behavior?

Named parameters are normalized before parsing, but parameters used as SQL
identifiers need a synthetic identifier placeholder because PostgreSQL does not
accept positional parameters in relation or qualifier positions.

For example, :raw_data.documents is normalized to a parser-compatible form
such as a.documents. Parsing succeeds, but typechecking then reports the
false positive relation "a.documents" does not exist.

Fixes #787.

What is the new behavior?

Named parameters are classified by SQL context:

  • value parameters continue to become positional parameters;
  • identifier parameters, including qualified names such as
    :raw_data.documents, become length-preserving synthetic identifiers for
    parsing;
  • PostgreSQL typechecking is skipped only for the statement containing an
    unresolved named identifier parameter.

Parsing, syntax diagnostics, linting, and plpgsql_check remain enabled.
Other statements in the same file continue to be typechecked normally.

Additional context

The conversion keeps the original byte length so parser diagnostic offsets stay
aligned with the source document.

The change does not attempt to resolve external aliases such as raw_data.
A future dbsh integration may provide that semantic context.

The named-parameter normalization is purely lexical and is about to be needed by the statement splitter as well. Moving it to pgls_lexer keeps the splitter and the workspace in agreement about what counts as parsable SQL.

Pure move: no signature, body or comment changed.
@edjubert edjubert changed the title fix(lexer): normalize named parameters by SQL context fix: handle named parameters in identifier contexts Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Named parameters are tokenized but never substituted, so any file using them fails to parse

1 participant