Opened 5 years ago
Last modified 4 years ago
#30916 closed New feature
Add support for case insensitive unique constraint — at Version 2
Reported by: | Safwan Rahman | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | constraint functional |
Cc: | Ian Foote, Hannes Ljungberg | 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 (last modified by )
Case insensitive unique constraint is needed for various purposes like storing emails. In postgresql, its possible to add a functional unique index with `Lower` and it will work as a case insensitive unique constraint. I have tried to implement that functional unique index/constraint in django, but looking at the source it seems that it is not possible to add functional unique index/constraint in django. PR 11929 is created for adding functional index, but it seems like it is not possible to create unique functional index with it.
I think there should be a option like case_insensitive=True
that can be passed to UniqueConstraint
so the UniqueConstraint
create a functional unique index with Lower
.
I know, its possible to store the value as lower case always and mitigate this issue, but it does not provide DB level constrains safety from anomaly.
Change History (2)
comment:1 by , 5 years ago
Description: | modified (diff) |
---|
comment:2 by , 5 years ago
Description: | modified (diff) |
---|