Hi y'all,
Django 3.2+ supports "db_collation" [1] for "CharField" and
"TextField" along with migration operations ("CreateCollation()",
"RemoveCollation") and the database function "Collate()" [3].
Moreover CI fields and the entire "citext" module are discouraged
since PostgreSQL 12 [4] in favor of collations. I think it's time to
deprecate CI fields from the
"contrib.postgres" in favor of "CharField" and "TextField" with
case insensitive collations (and remove them in Django 5.0).
Best,
Mariusz
[1]
https://code.djangoproject.com/ticket/31777
[2] https://code.djangoproject.com/ticket/32046
[3] https://code.djangoproject.com/ticket/21181
[4] https://www.postgresql.org/docs/12/citext.html
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/833bb13b-3db1-f35b-3d51-a2a4671b45a9%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAKFO%2Bx5j8Y6%2BMH_%2Bug-BGKZ6qaWD9tRWVLXLOXhmTQuvrN8tzw%40mail.gmail.com.
My initial concern was around the minimum PostgreSQL version that Django 5.0 will support. According to https://en.wikipedia.org/wiki/PostgreSQL#Release_history , PostgreSQL 10 is supported until 2022-11-10 , and version 11 until 2023-11-09. With Django 5.0 expected in 2024-01, it should be fine to deprecate the CI fields for removal in Django 5.0. Users on old PostgreSQL versions can manage the deprecation warning until they upgrade.
https://code.djangoproject.com/ticket/33872
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/5c11b704-68c4-490d-84bf-90c734cc02d1n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAHoz%3DMb25iGN%2BHodxgE6Y%2B5d%2B5qoHERvkMiuiHrs%3DXnpeC%3D-xg%40mail.gmail.com.
You received this message because you are subscribed to a topic in the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-developers/nDMnO98nexY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM3PuF92jEdTocGPtG%2Bq0n%2B%3DfRfZ05gTw8w3T6kZ5p6xBQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/5108100c-2967-4a8e-9840-59d187f895cdn%40googlegroups.com.
What I am struggling now with is whenever I specify `db_collation="case_insensitive"` on the field and this field is used in `ModelAdmin.search_fields` - Django simply breaks (as it by default uses `icontains` lookup).
That is quite unfortunate for the big projects, as I have to come up with some generic solution to something that was not broken before this feature deprecation (and the docs does not mention this case).
Good that Adam covered it in the article, but I feel that this could be handled on a lower level than right now. Currently, we'd need to write a manual annotation for admin queryset in almost every project that uses usernames or emails (which my guess is something you'd want to be case-insensitive on a database level).
I actually think the best practice right now for having searchable case-insensitive emails is to do it old-school - have a regular EmailField with an index on UPPER("email") and then make sure you always use iexact, istartswith etc. and this will properly use the indexes and result in a faster search.
For example, in terms of documentation, we could add a note on `db_collation` to `icontains` page:
https://docs.djangoproject.com/en/4.2/ref/models/querysets/#icontains
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAPcC2o%3DWPmKDxCD5zZHwJs5jB3XEXzBZh79qnDYdSD85T1Y3wQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM0ccp%3D2o7koMoRL6b46hM%3DYAQGQsJiEdTjiJw%3Dq-87NyQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/cad104f0-cd96-4235-839e-4cd344f90184n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/42b2a310-a4d7-4fb9-9d0e-19c94f58fc5fn%40googlegroups.com.