#34701: Add support for NULLS [NOT] DISTINCT to UniqueConstraint
-------------------------------------+-------------------------------------
     Reporter:  Simon Charette       |                    Owner:  nobody
         Type:  New feature          |                   Status:  assigned
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Simon Charette:

Old description:

> 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]

New description:

 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#comment:1>
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/0107018932bd25af-25738271-f39b-4592-a3d9-d40730837bd9-000000%40eu-central-1.amazonses.com.

Reply via email to