#36880: using hash index as exclusion constraint on USERNAME_FIELD triggers
SystemCheckError
-------------------------------------+-------------------------------------
Reporter: Tilman Koschnick | Type: Bug
Status: new | Component: Database
| layer (models, ORM)
Version: dev | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Hi,
with Postgres, a hash index can be used as an exclusion constraint,
functioning the same way a unique btree based constrained. Support for
this has recently been merged to Django:
[
https://code.djangoproject.com/ticket/36827]
Using this on a USERNAME_FIELD can be good for index size and performance.
Currently, the auth system checks doesn't detect a hash exclusion
constraint as a viable option though:
{{{
account.User: (auth.E003) 'User.email' must be unique because it is named
as the 'USERNAME_FIELD'.
}}}
The attached patch enhances the check to consider hash constraints as
well.
Cheers, Til
--
Ticket URL: <
https://code.djangoproject.com/ticket/36880>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.