#34701: Add support for NULLS [NOT] DISTINCT to UniqueConstraint
-------------------------------------+-------------------------------------
Reporter: Simon | Owner: nobody
Charette |
Type: New | Status: assigned
feature |
Component: Database | Version: 4.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
PostgresSQL 15 is one of the first databases to implement the F292 SQL
feature present in the 2023 standard that allows to specify whether or not
null values should be considered as distinct in unique constraints.
While most backends default to implicit `NULLS DISTINCT` some backends
don't, most notably SQL Server (cff59bedc23fd4d53557f677ddc42402b56963d0).
I suggest we add a `nulls_distinct: Optional[bool]=None` option to
`UniqueConstraint` so it preserves it's ''default to backend treatment of
nulls'' behaviour while allowing it to be set explicitly on backends that
support it.
- [https://modern-sql.com/caniuse/unique-nulls-not-distinct Article on the
subject]
- [https://modern-sql.com/caniuse/F292 SQL:F292]
- [https://forum.djangoproject.com/t/support-nulls-not-distinct-
postgres-15-clause/21973/3 Recent thread on the subject in the forums]
--
Ticket URL: <https://code.djangoproject.com/ticket/34701>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018932bc7659-f2f612d1-c99b-4101-ada3-4dee42bfe803-000000%40eu-central-1.amazonses.com.