Skip to content

Support schema-qualified collation in types for PostgreSQL #12697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dlax
Copy link
Contributor

@dlax dlax commented Jun 25, 2025

We add a collation_schema in types supporting collation, along with
postgresql.DOMAIN, allowing to create respective elements with a
schema-qualified collation name.

Reflection is also handled for both types and domains.

Fix #9693.

@dlax
Copy link
Contributor Author

dlax commented Jun 25, 2025

notes:

dlax added 6 commits July 15, 2025 12:31
The 'collation' returned by PGDialect._columns_query() is None if it
matches the default collation for the type. On the other hand, if the
column collation matches the one of the database but is explicitly set
at column creation, the value is reflected.

Related to sqlalchemy#6511.
Following a similar approach to 703a323.

The CAST(..., BIGINT) for array_agg()'s elements is needed for pg8000.
The previous `if` clause was wrong as it would match the `else` branch
if `default_collation_for_types` was `None` whereas we only want that
branch to match if the type is in `default_collation_for_types` array.
Otherwise, reflection.cache() decorator does not work.
This avoids a join on pg_collation in _domain_query().
We add a `collation_schema` in types supporting `collation`, along with
`postgresql.DOMAIN`, allowing to create respective elements with a
schema-qualified collation name.

Reflection is also handled for both types and domains.

Fix sqlalchemy#9693.
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.

Text type columns using schema qualified collations compile a quoted DDL statement on Postgres
1 participant