Skip to content

Fix Postgres schema-qualified autocomplete#252

Open
Maxteabag wants to merge 1 commit into
mainfrom
fix/postgres-schema-autocomplete
Open

Fix Postgres schema-qualified autocomplete#252
Maxteabag wants to merge 1 commit into
mainfrom
fix/postgres-schema-autocomplete

Conversation

@Maxteabag
Copy link
Copy Markdown
Owner

Summary

  • keep default-schema autocomplete unqualified while exposing non-default schema objects as schema.table
  • derive schema suggestions from qualified table cache entries and narrow schema. completions to tables inside that schema
  • add unit regressions plus a Docker-backed PostgreSQL integration test for test.hello_world

Verification

  • 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
  • uv run mypy sqlit/domains/query/completion
  • uv run pytest tests/unit/test_autocomplete_multidb.py tests/unit/test_autocomplete_alias_multi_db.py tests/unit/sql_completion -q
  • 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

Notes

  • The Postgres compose service was stopped after verification.
  • Full all-provider integration suite was not run.

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
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