Skip to content

Config for setting collation for attributes #650

@barnabasJ

Description

@barnabasJ

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Is your feature request related to a problem? Please describe.

When working with a shared PostgreSQL database that's also used by Django (since Django 4.2's deprecation of CITextField), you can't use ilike filters anymore on columns that Django has set up with nondeterministic collations.
Django deprecated CITextField and now prefers setting db_collation on regular text fields to handle case-insensitive comparisons. The problem is that when Django creates a column with one of these nondeterministic collations, PostgreSQL throws errors if you try to use LIKE or ILIKE operators on those columns.

To Reproduce

Have a Django app that creates a table with a text field using db_collation for case-insensitive matching
Try to query that table from Ash/Ecto using an ILIKE filter
PostgreSQL will error because ILIKE doesn't work with nondeterministic collations

Describe the solution you'd like

It would be nice to have a way to specify a collation on an Ash attribute that gets applied at the query level (not in migrations - we can't change the column definition since that would break Django). Something that would generate SQL like:

WHERE column_name COLLATE "default" ILIKE '%search%'

This way Ash could work with Django's collation setup without modifying the actual column definitions.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions