Opened 7 years ago
Last modified 5 years ago
#29145 closed Cleanup/optimization
CIText and __eq__ — at Initial Version
Reported by: | Дилян Палаузов | Owned by: | nobody |
---|---|---|---|
Component: | contrib.postgres | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
For comparing two model instances on equality one can iterate over all fields in the instance and compare the fields for equality, without querying the database. This does not work for django.contrib.postgres.fields.citext.CIText, where "a" is equal to "A".
Under the premise that python and postgresql use the same collation, tweak the system to compare two citext-fields in a case-insensitive manner for equality, without touching the database (as it is done for all other fields).
Attaching to each citext-field returned from the model an __eq__
doing .lower()
could help.