Repository navigation
Conversation
…ote_identifier Expand star had its own quote_identifier, which quoted every keyword that isn't unreserved. It now uses pgls_catalog::quote_identifier: the first name of a column as a ColId, the names after a dot as labels. A column name keyword like `between` and any keyword after a dot, as in `t.select`, are no longer quoted, as Postgres reads them as the column.
This branch has not been deployed
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.
Stacked on #981.
Follow-up to the review of #932: the local
quote_identifierinworkspace/server/expand_star.rs"should be a helper in catalog". #981 adds that helper,pgls_catalog::quote_identifier(name, NamePosition), so expand star now uses it and its own copy is gone.The catalog's version knows where a name is written, so the expanded list changes a little. The old helper quoted every keyword that isn't unreserved, like Postgres'
quote_identifier. Now the first name of each column is quoted as aColIdand the names after a dot as labels:More precisely:
between,int,time,values, ...) is no longer quoted, also without a qualifier.t.select,public."Posts".user.select,user) and type or function name keywords (left,join) are still quoted as the first name.I checked this against the Postgres 15 test database for all 151 keywords that aren't unreserved there: every column name keyword parses unquoted as the only, the first and the last item of a select list, and returns the column's value, and so does every keyword after a dot. Reserved and type or function name keywords fail to parse without quotes as the first name, which is why they stay quoted there. Keywords added in Postgres 16 and 17 (
json_table,merge_action, ...) aren't covered by that check; they follow the samegram.ycategories.column_listalso no longer runs the scanner once per name;keyword_categoryis a table lookup.This PR changes
workspace/server/expand_star.rswhere it is on main. #990 moves that file tofeatures/code_actions/expand_star.rswithout changing it otherwise, and a trial merge of #990 into this branch applies this change to the moved file without conflicts.Tests
quotes_names_where_postgres_needs_itreplaces the unit test of the removed helper and goes throughcolumn_list: a column name keyword, a reserved and a type or function name keyword with and without a qualifier, upper case, a space,", and names that aren't ASCII.qualifies_columnsandtest_code_actions_expand_starnow expectpublic."Posts".userandt.select.cargo test -p pgls_workspace --lib -- expand_star,cargo test -p pgls_lsp -- expand_starandcargo clippy --workspace --all-targets -- -D warningspass.