Opened 2 years ago

Closed 2 years ago

Last modified 4 months ago

#33872 closed Cleanup/optimization (fixed)

Deprecate CICharField, CIEmailField, CITextField.

Reported by: Mariusz Felisiak Owned by: Mariusz Felisiak
Component: contrib.postgres Version: dev
Severity: Normal Keywords:
Cc: Tom Carrick, Carlton Gibson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django 3.2+ supports db_collation for CharField and TextField (see #31777) along with migration operations (CreateCollation(), RemoveCollation()) and the database function Collate() (see #21181). Moreover CI fields and the entire citext module are discouraged since PostgreSQL 12 (which is the minimum version supported by Django 4.2+) 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.

Related discussion on the django-developers mailing list.

Change History (10)

comment:1 by Mariusz Felisiak, 2 years ago

Owner: set to Mariusz Felisiak
Status: newassigned

comment:2 by Carlton Gibson, 2 years ago

Triage Stage: UnreviewedAccepted

Accepting based on discussion (+3:-0 I think)

Points were to ensure we document a migration, and perhaps how to avoid needing the CI field ("...put an index on UPPER and make sure you always use iexact.")

comment:3 by Mariusz Felisiak, 2 years ago

Has patch: set

comment:4 by Carlton Gibson, 2 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by GitHub <noreply@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In cb791a25:

Fixed #33872 -- Deprecated django.contrib.postgres.fields.CIText/CICharField/CIEmailField/CITextField.

comment:6 by Johannes Maron, 21 months ago

Triage Stage: Ready for checkinUnreviewed

In case my mailing list comment gets lost, I make this as unreviewed and leave a copy here:

Hi there,

I am sorry that I missed this in the alpha. But to the best of my knowledge, CITEXT and non-deterministic collations are not the same. They don't support the same operations and their string comparison operations are similar, yet not identical.
Furthermore, PostgreSQL doesn't discourage the use of CITEXT, but hints towards a native alternative. That's maybe more than just a subtle difference.

99% of all use-cases might be email, but even email LIKE-queries would be affected (good for +-searches).

Unless we want to drop support for the CITEXT extension, collations might not be a sufficient replacement.

I'd caution to revert the deprecation and keep support unless we make an informed decision to drop CITEXT for a 3rd party integration.

Best
Joe!

comment:7 by Mariusz Felisiak, 21 months ago

Triage Stage: UnreviewedReady for checkin

Please don't reopen/change closed tickets. If you want to report a bug, create a separate ticket.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 15 months ago

In 04eb1b4:

Refs #33872 -- Removed django.contrib.postgres.fields.CIText/CICharField/CIEmailField/CITextField.

Per deprecation timeline.

comment:9 by Gavin Wahl, 4 months ago

I think this should be reverted, there is no consensus for this deprecation on the mailing list: https://groups.google.com/g/django-developers/c/nDMnO98nexY

comment:10 by Mariusz Felisiak, 4 months ago

It's no longer a deprecation, CIText/CICharField/CIEmailField/CITextField have already been removed in Django 5.1, and (as far as I'm aware) it's too late to change this decision and add them back to the core. You can always use django-citext if really need to use them.

Note: See TracTickets for help on using tickets.
Back to Top