Skip to content

Quote Postgres autocomplete suggestions for mixed-case identifiers#268

Open
Maxteabag wants to merge 1 commit into
mainfrom
test/issue-262-postgres-quoted-autocomplete
Open

Quote Postgres autocomplete suggestions for mixed-case identifiers#268
Maxteabag wants to merge 1 commit into
mainfrom
test/issue-262-postgres-quoted-autocomplete

Conversation

@Maxteabag

Copy link
Copy Markdown
Owner

Fixes #262.

Postgres folds unquoted identifiers to lowercase, so accepting autocomplete for PascalCase tables or camelCase columns produced SQL that failed against real schemas. The fix keeps raw schema metadata for lookup and lazy loading, but formats dropdown insertion text through a dialect hook. The default hook preserves existing behavior; Postgres quotes only identifiers that are not safe lowercase unquoted names.

Constraint: PostgreSQL quoted identifiers preserve case while unquoted identifiers fold to lowercase

Rejected: Quote every autocomplete identifier | too noisy and would degrade normal lowercase workflows

Rejected: Rewrite schema cache entries as quoted names | risks breaking raw metadata lookup and column loading

Confidence: high

Scope-risk: moderate

Directive: Keep autocomplete display formatting separate from raw schema metadata unless lookup tests are updated alongside it

Tested: uv run ruff check sqlit/domains/connections/providers/adapters/base.py sqlit/domains/connections/providers/postgresql/base.py sqlit/domains/query/ui/mixins/autocomplete_suggestions.py tests/integration/test_autocomplete_postgresql_schema.py

Tested: uv run mypy sqlit/domains/connections/providers/adapters/base.py sqlit/domains/connections/providers/postgresql/base.py sqlit/domains/query/ui/mixins/autocomplete_suggestions.py

Tested: uv run --extra postgres pytest tests/integration/test_autocomplete_postgresql_schema.py tests/unit/test_autocomplete_multidb.py tests/unit/test_autocomplete_alias_multi_db.py tests/unit/sql_completion tests/test_autocomplete_database_modes.py tests/ui/test_autocomplete_dropdown.py tests/integration/test_autocomplete_mysql_columns.py -q

Not-tested: Full provider integration matrix beyond autocomplete-focused tests
@Maxteabag Maxteabag marked this pull request as ready for review July 10, 2026 14:42
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.

How to quote identifiers in postgresql?

1 participant