summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2023-07-07 19:43:51 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-07-19 21:42:27 +0200
commit595a2abb58e04caa4d55fb2589bb80fb2a8fdfa1 (patch)
treef08cf5a71a9d637818d896a7b31b2d7860e336ca /docs/ref
parent98cfb90182a8baa806fc4e09e294b6cfc5d09eff (diff)
Fixed #34701 -- Added support for NULLS [NOT] DISTINCT on PostgreSQL 15+.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/checks.txt2
-rw-r--r--docs/ref/models/constraints.txt22
2 files changed, 23 insertions, 1 deletions
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt
index 9e1381c31f..a208114596 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -408,6 +408,8 @@ Models
expression and won't be validated during the model ``full_clean()``.
* **models.W046**: ``<database>`` does not support comments on tables
(``db_table_comment``).
+* **models.W047**: ``<database>`` does not support unique constraints with
+ nulls distinct.
Security
--------
diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt
index 4ed5b65d46..efe63a8ac1 100644
--- a/docs/ref/models/constraints.txt
+++ b/docs/ref/models/constraints.txt
@@ -131,7 +131,7 @@ ensures the age field is never less than 18.
``UniqueConstraint``
====================
-.. class:: UniqueConstraint(*expressions, fields=(), name=None, condition=None, deferrable=None, include=None, opclasses=(), violation_error_code=None, violation_error_message=None)
+.. class:: UniqueConstraint(*expressions, fields=(), name=None, condition=None, deferrable=None, include=None, opclasses=(), nulls_distinct=None, violation_error_code=None, violation_error_message=None)
Creates a unique constraint in the database.
@@ -254,6 +254,26 @@ creates a unique index on ``username`` using ``varchar_pattern_ops``.
``opclasses`` are ignored for databases besides PostgreSQL.
+``nulls_distinct``
+------------------
+
+.. versionadded:: 5.0
+
+.. attribute:: UniqueConstraint.nulls_distinct
+
+Whether rows containing ``NULL`` values covered by the unique constraint should
+be considered distinct from each other. The default value is ``None`` which
+uses the database default which is ``True`` on most backends.
+
+For example::
+
+ UniqueConstraint(name="ordering", fields=["ordering"], nulls_distinct=False)
+
+creates a unique constraint that only allows one row to store a ``NULL`` value
+in the ``ordering`` column.
+
+``nulls_distinct`` is ignored for databases besides PostgreSQL 15+.
+
``violation_error_code``
------------------------