Deprecate CICharField, CIEmailField, CITextField

356 views
Skip to first unread message

Mariusz Felisiak

unread,
Jan 25, 2022, 7:39:32 AM1/25/22
to django-d...@googlegroups.com

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

Adam Johnson

unread,
Jan 25, 2022, 7:59:54 AM1/25/22
to Django developers (Contributions to Django itself)
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.

So +1 from me.

--
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.

Paolo Melchiorre

unread,
Jan 25, 2022, 8:01:55 AM1/25/22
to django-d...@googlegroups.com
Hi Mariusz,

I agree with you on deprecating and then removing CI fields.

I only would suggest adding some examples of migrations from CI fields
to collations in the deprecation notes to help users to easily
migrate.

So +1 for me too.

Ciao,
Paolo
> --
> 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.



--
Paolo Melchiorre

https://www.paulox.net

Tom Carrick

unread,
Jan 25, 2022, 9:17:07 AM1/25/22
to django-d...@googlegroups.com
Hi,

I'm not too sure about this.

While Postgres encourages using non-deterministic collations, they're not without their downsides. For example, you can't do a LIKE query on a field using a non-deterministic collation, but you can with CItext - although I don't believe there's a way to index it. Say, for example, you want to store your user emails CI - this is great for logging in but it makes it impossible to search for users with a particular email domain, or trying to find someone by the username part, say.

On the other hand, we could just say: don't use either, put an index on UPPER and make sure you always use iexact.

I don't have a very strong opinion.

Cheers,
Tom


Mariusz Felisiak

unread,
Jan 25, 2022, 2:25:00 PM1/25/22
to Django developers (Contributions to Django itself)
wtorek, 25 stycznia 2022 o 13:59:54 UTC+1 Adam Johnson napisał(a):
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.

Yes, support for PostgreSQL 10 will be dropped in Django 4.2, and support for PostgreSQL 11 will be dropped in Django 5.0.
 

Mariusz Felisiak

unread,
Jul 28, 2022, 6:55:39 AM7/28/22
to Django developers (Contributions to Django itself)
> Support for PostgreSQL 10 was dropped in Django 4.1, and support for PostgreSQL 11 was dropped in Django 4.2.

When CICharField, CIEmailField, CITextField deprecation starts in Django 4.2 they will be removed in Django 5.1.

Mariusz Felisiak

unread,
Jul 28, 2022, 7:03:10 AM7/28/22
to Django developers (Contributions to Django itself)

Silvio

unread,
Aug 6, 2022, 3:32:05 PM8/6/22
to Django developers (Contributions to Django itself)
Since these are PotsgreSQL-specific fields that are being deprecated, might it make sense to provide a hint as to what the CreateCollation() call should be?

I'm looking around and it's not immediately obvious. The CreateCollation() examples in Django are for a German phone book, where in reality, I think 99% of cases are going to be for case insensitive emails.

The deprecation notice in the patch currently shows an ellipsis.
On Thursday, July 28, 2022 at 7:03:10 AM UTC-4 Mariusz Felisiak wrote:
https://code.djangoproject.com/ticket/33872

Mariusz Felisiak

unread,
Aug 8, 2022, 5:49:25 AM8/8/22
to Django developers (Contributions to Django itself)
As far as I'm aware you can use:

     CreateCollation("case_insensitive", "und-u-ks-level2", provider="icu", deterministic=False)

to create a case insensitive collation on PostgreSQL.

Reply all
Reply to author
Forward
0 new messages