Skip to content

Handle schema-qualified collation value in collate() #12698

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 7 commits into
base: main
Choose a base branch
from

Conversation

dlax
Copy link
Contributor

@dlax dlax commented Jun 25, 2025

based on #12697 (and #12510).

dlax added 7 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.
@dlax dlax force-pushed the collate-schema branch from fd542af to 1d472f0 Compare July 22, 2025 12:49
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