Fix Postgres schema-qualified autocomplete#252
Open
Maxteabag wants to merge 1 commit into
Open
Conversation
PostgreSQL tables outside the default schema were cached as bare table names in single-database mode. That made autocomplete suggest invalid SQL like hello_world even though the executable relation was test.hello_world, and schema-dot completion could not narrow to tables in the typed schema. This change keeps default-schema tables unqualified, exposes non-default schema objects as schema.table, and teaches completion to derive schema names plus schema-local table suggestions from qualified cache entries. The regression coverage includes direct completion tests and a Docker-backed PostgreSQL integration case for test.hello_world. Constraint: PostgreSQL schemas are separate namespaces even when only one database is connected Rejected: Always qualify every table | would regress simple default-schema autocomplete for common public tables Rejected: Postgres-only special case in the adapter | completion already consumes provider-neutral qualified names from several backends Confidence: high Scope-risk: moderate Reversibility: clean Directive: Do not cache non-default schema objects as bare names unless search_path handling is explicitly modeled Tested: uv run ruff check sqlit/domains/query/completion/core.py sqlit/domains/query/completion/completion.py sqlit/domains/query/ui/mixins/autocomplete_schema.py tests/unit/test_autocomplete_multidb.py tests/integration/test_autocomplete_postgresql_schema.py Tested: uv run mypy sqlit/domains/query/completion Tested: uv run pytest tests/unit/test_autocomplete_multidb.py tests/unit/test_autocomplete_alias_multi_db.py tests/unit/sql_completion -q Tested: docker compose -f infra/docker/docker-compose.test.yml up -d postgres && uv run --extra postgres pytest tests/integration/test_autocomplete_postgresql_schema.py -q Not-tested: Full all-provider integration suite
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.
Summary
schema.tableschema.completions to tables inside that schematest.hello_worldVerification
uv run ruff check sqlit/domains/query/completion/core.py sqlit/domains/query/completion/completion.py sqlit/domains/query/ui/mixins/autocomplete_schema.py tests/unit/test_autocomplete_multidb.py tests/integration/test_autocomplete_postgresql_schema.pyuv run mypy sqlit/domains/query/completionuv run pytest tests/unit/test_autocomplete_multidb.py tests/unit/test_autocomplete_alias_multi_db.py tests/unit/sql_completion -qdocker compose -f infra/docker/docker-compose.test.yml up -d postgres && uv run --extra postgres pytest tests/integration/test_autocomplete_postgresql_schema.py -qNotes