fix: handle named parameters in identifier contexts - #790
Open
edjubert wants to merge 6 commits into
Open
Conversation
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.
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.
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.documentsis normalized to a parser-compatible formsuch as
a.documents. Parsing succeeds, but typechecking then reports thefalse positive
relation "a.documents" does not exist.Fixes #787.
What is the new behavior?
Named parameters are classified by SQL context:
:raw_data.documents, become length-preserving synthetic identifiers forparsing;
unresolved named identifier parameter.
Parsing, syntax diagnostics, linting, and
plpgsql_checkremain 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.