fix(plugin-postgresql): complete autocomplete for tables and columns in non-active schemas (#1668)#1674
Merged
Merged
Conversation
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.
Fixes #1668.
Problem
PostgreSQL autocomplete only completed tables and columns from the schema selected in the sidebar. A schema-qualified query like
SELECT * FROM s2.ordersgot no completions fors2's columns whens1was the active schema.Root cause
The completion engine threads the referenced schema all the way down (parser,
SQLSchemaProvider,SchemaProviderRegistry), but the drivers discarded it on the last hop:PostgreSQLPluginDriver.fetchColumns/fetchAllColumnshardcodedcurrentSchema ?? "public"and ignored theirschemaparameter.escapedSchemaconvenience pinned tocurrentSchema, so its cross-schema completion failed for both tables and columns.CockroachDB (same plugin bundle) already resolved
schema ?? currentSchemacorrectly and was the reference.Fix
schema ?? currentSchema) in the PostgreSQL and Redshift column/structure queries.escapedSchemafootgun fromLibPQBackedDriverand threaded the parameter through every method that used it (columns, foreign keys, DDL, view definitions, table metadata, dependent types/sequences).PostgreSQLSchemaQueries.columnsQuery,RedshiftSchemaQueries.columnsQuery) so the schema-threading is unit-tested.No PluginKit ABI change (all changes are internal to the PostgreSQL plugin bundle).
Tests
New
PostgreSQLColumnQueryTestscovers both builders: the requested schema (including non-active schemas) threads into the WHERE and PK clauses, single-table vs all-tables shapes are correct. The builders compile into the test target via the existingPluginTestSourcessymlink mechanism, so they run without the libpq C bridge.Notes
docs/features/autocomplete.mdx); this makes PostgreSQL match the docs.fetchIndexeshas a separate, pre-existing missing-schema-filter ambiguity (not autocomplete, not theescapedSchemafootgun).