summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorHannes Ljungberg <hannes@5monkeys.se>2020-06-11 21:37:12 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-16 07:19:00 +0200
commit7edc6e53a746af995e3b89d53d37938dd8fc46aa (patch)
tree9cf8c4745a2051d87606f121080ee1098e7b2092 /docs
parent69e0d9c553bb55dde8d7d1d479a78bfa7093f406 (diff)
Fixed #31702 -- Added support for PostgreSQL opclasses in UniqueConstraint.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/constraints.txt23
-rw-r--r--docs/releases/3.2.txt3
2 files changed, 25 insertions, 1 deletions
diff --git a/docs/ref/models/constraints.txt b/docs/ref/models/constraints.txt
index 819bb3a20b..1536a8692a 100644
--- a/docs/ref/models/constraints.txt
+++ b/docs/ref/models/constraints.txt
@@ -73,7 +73,7 @@ constraint.
``UniqueConstraint``
====================
-.. class:: UniqueConstraint(*, fields, name, condition=None, deferrable=None, include=None)
+.. class:: UniqueConstraint(*, fields, name, condition=None, deferrable=None, include=None, opclasses=())
Creates a unique constraint in the database.
@@ -168,3 +168,24 @@ while fetching data only from the index.
``include`` is supported only on PostgreSQL.
Non-key columns have the same database restrictions as :attr:`Index.include`.
+
+
+``opclasses``
+-------------
+
+.. attribute:: UniqueConstraint.opclasses
+
+.. versionadded:: 3.2
+
+The names of the `PostgreSQL operator classes
+<https://www.postgresql.org/docs/current/indexes-opclass.html>`_ to use for
+this unique index. If you require a custom operator class, you must provide one
+for each field in the index.
+
+For example::
+
+ UniqueConstraint(name='unique_username', fields=['username'], opclasses=['varchar_pattern_ops'])
+
+creates a unique index on ``username`` using ``varchar_pattern_ops``.
+
+``opclasses`` are ignored for databases besides PostgreSQL.
diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt
index 3b831ee8ec..416530400e 100644
--- a/docs/releases/3.2.txt
+++ b/docs/releases/3.2.txt
@@ -196,6 +196,9 @@ Models
attributes allow creating covering indexes and covering unique constraints on
PostgreSQL 11+.
+* The new :attr:`.UniqueConstraint.opclasses` attribute allows setting
+ PostgreSQL operator classes.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~