summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorIan Foote <python@ian.feete.org>2020-04-12 11:43:16 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-01 09:08:36 +0200
commitb4068bc65636cca6c2905aa8c40bea69bb0e4245 (patch)
tree578a412d31851d728f303652619056e031d4219d /docs/ref
parent5d2f5dd4cc5234a97d69af8740ba862c2051fd43 (diff)
Fixed #31455 -- Added support for deferrable exclusion constraints on PostgreSQL.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/contrib/postgres/constraints.txt34
1 files changed, 33 insertions, 1 deletions
diff --git a/docs/ref/contrib/postgres/constraints.txt b/docs/ref/contrib/postgres/constraints.txt
index fe9e72e605..acc592fc1e 100644
--- a/docs/ref/contrib/postgres/constraints.txt
+++ b/docs/ref/contrib/postgres/constraints.txt
@@ -14,7 +14,7 @@ PostgreSQL supports additional data integrity constraints available from the
.. versionadded:: 3.0
-.. class:: ExclusionConstraint(*, name, expressions, index_type=None, condition=None)
+.. class:: ExclusionConstraint(*, name, expressions, index_type=None, condition=None, deferrable=None)
Creates an exclusion constraint in the database. Internally, PostgreSQL
implements exclusion constraints using indexes. The default index type is
@@ -76,6 +76,38 @@ a constraint to a subset of rows. For example,
These conditions have the same database restrictions as
:attr:`django.db.models.Index.condition`.
+``deferrable``
+--------------
+
+.. attribute:: ExclusionConstraint.deferrable
+
+.. versionadded:: 3.1
+
+Set this parameter to create a deferrable exclusion constraint. Accepted values
+are ``Deferrable.DEFERRED`` or ``Deferrable.IMMEDIATE``. For example::
+
+ from django.contrib.postgres.constraints import ExclusionConstraint
+ from django.contrib.postgres.fields import RangeOperators
+ from django.db.models import Deferrable
+
+
+ ExclusionConstraint(
+ name='exclude_overlapping_deferred',
+ expressions=[
+ ('timespan', RangeOperators.OVERLAPS),
+ ],
+ deferrable=Deferrable.DEFERRED,
+ )
+
+By default constraints are not deferred. A deferred constraint will not be
+enforced until the end of the transaction. An immediate constraint will be
+enforced immediately after every command.
+
+.. warning::
+
+ Deferred exclusion constraints may lead to a `performance penalty
+ <https://www.postgresql.org/docs/current/sql-createtable.html#id-1.9.3.85.9.4>`_.
+
Examples
--------