summaryrefslogtreecommitdiff
path: root/docs/ref/contrib/postgres
diff options
context:
space:
mode:
authorHannes Ljungberg <hannes.ljungberg@gmail.com>2021-02-06 20:45:54 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-02-23 20:19:53 +0100
commit3aa545281e0c0f9fac93753e3769df9e0334dbaa (patch)
tree454bec922a78df9ecfe6eab197e7750e8a5bafac /docs/ref/contrib/postgres
parent19ce1d493ae7cbc1e704d338077b1f5f5e5769c9 (diff)
Fixed #30916 -- Added support for functional unique constraints.
Thanks Ian Foote and Mariusz Felisiak for reviews.
Diffstat (limited to 'docs/ref/contrib/postgres')
-rw-r--r--docs/ref/contrib/postgres/indexes.txt22
1 files changed, 18 insertions, 4 deletions
diff --git a/docs/ref/contrib/postgres/indexes.txt b/docs/ref/contrib/postgres/indexes.txt
index b6a4aba808..9a9b7fc73b 100644
--- a/docs/ref/contrib/postgres/indexes.txt
+++ b/docs/ref/contrib/postgres/indexes.txt
@@ -183,10 +183,10 @@ available from the ``django.contrib.postgres.indexes`` module.
.. class:: OpClass(expression, name)
An ``OpClass()`` expression represents the ``expression`` with a custom
- `operator class`_ that can be used to define functional indexes. To use it,
- you need to add ``'django.contrib.postgres'`` in your
- :setting:`INSTALLED_APPS`. Set the ``name`` parameter to the name of the
- `operator class`_.
+ `operator class`_ that can be used to define functional indexes or unique
+ constraints. To use it, you need to add ``'django.contrib.postgres'`` in
+ your :setting:`INSTALLED_APPS`. Set the ``name`` parameter to the name of
+ the `operator class`_.
For example::
@@ -197,4 +197,18 @@ available from the ``django.contrib.postgres.indexes`` module.
creates an index on ``Lower('username')`` using ``varchar_pattern_ops``.
+ Another example::
+
+ UniqueConstraint(
+ OpClass(Upper('description'), name='text_pattern_ops'),
+ name='upper_description_unique',
+ )
+
+ creates a unique constraint on ``Upper('description')`` using
+ ``text_pattern_ops``.
+
+ .. versionchanged:: 4.0
+
+ Support for functional unique constraints was added.
+
.. _operator class: https://www.postgresql.org/docs/current/indexes-opclass.html