Skip to content

feat(completions): offer the columns each MERGE branch can see - #1133

Open
psteinroe wants to merge 1 commit into
feat/completions-mergefrom
feat/completions-merge-visibility
Open

psteinroe wants to merge 1 commit into
feat/completions-mergefrom
feat/completions-merge-visibility

Conversation

@psteinroe

Copy link
Copy Markdown
Collaborator

Stacked on #1130.

Completions inside MERGE (#1130) offered the columns of the target and the source in every WHEN clause. Postgres restricts what each branch sees (setNamespaceForMergeWhen), and so does the resolver since #1122. NOT MATCHED ... VALUES (|) offered target columns that Postgres rejects there, and NOT MATCHED BY SOURCE offered source columns.

What changed

  • TreesitterContext works out which MERGE relation the WHEN clause under the cursor can't see. NOT MATCHED [BY TARGET] hides the target and NOT MATCHED BY SOURCE hides the source. The column lists of INSERT (...) and the targets of UPDATE SET hide the source, because they are always target columns. MATCHED hides nothing. If the target and the source are the same table, nothing is hidden, since the columns can't be told apart.
  • A new filter drops the columns and tables of the hidden relation. Qualified references follow too: t. for a hidden target offers nothing.

Tests

  • completes_the_columns_each_merge_branch_sees: the columns offered in MATCHED conditions and values, NOT MATCHED [BY TARGET] values and conditions, NOT MATCHED BY SOURCE conditions and values, the hidden alias, INSERT column lists, UPDATE SET targets, and a MERGE of a table into itself. It fails without the filter.
  • The completes_in_merge snapshot changes in six places: update set | and insert (| lose the source columns, and values (| loses the target columns.
  • cargo test -p pgls_completions -p pgls_treesitter -p pgls_hover, cargo clippy --workspace --all-targets -- -D warnings.

Not covered

  • A subquery source has no catalog columns to hide, so only a table source is hidden by name.

This branch has not been deployed

No deployments
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.

1 participant