summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/constraints.py
diff options
context:
space:
mode:
authorHannes Ljungberg <hannes.ljungberg@gmail.com>2021-12-08 21:28:08 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-12-27 08:55:18 +0100
commit59a66f05126a4f9622f67ac71ccc149c805a6ccd (patch)
tree40116048347c6a83dc18cffa15d1ab51f9962669 /django/contrib/postgres/constraints.py
parentff225fac1d129d4bcfef0aeb03df6f3b20fbb23d (diff)
downloaddjango-59a66f05126a4f9622f67ac71ccc149c805a6ccd.tar.gz
Refs #33342 -- Deprecated ExclusionConstraint.opclasses.
Diffstat (limited to 'django/contrib/postgres/constraints.py')
-rw-r--r--django/contrib/postgres/constraints.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py
index a9ea4761b3..06ccd3616e 100644
--- a/django/contrib/postgres/constraints.py
+++ b/django/contrib/postgres/constraints.py
@@ -1,3 +1,5 @@
+import warnings
+
from django.contrib.postgres.indexes import OpClass
from django.db import NotSupportedError
from django.db.backends.ddl_references import Expressions, Statement, Table
@@ -6,6 +8,7 @@ from django.db.models.constraints import BaseConstraint
from django.db.models.expressions import ExpressionList
from django.db.models.indexes import IndexExpression
from django.db.models.sql import Query
+from django.utils.deprecation import RemovedInDjango50Warning
__all__ = ['ExclusionConstraint']
@@ -67,6 +70,14 @@ class ExclusionConstraint(BaseConstraint):
self.deferrable = deferrable
self.include = tuple(include) if include else ()
self.opclasses = opclasses
+ if self.opclasses:
+ warnings.warn(
+ 'The opclasses argument is deprecated in favor of using '
+ 'django.contrib.postgres.indexes.OpClass in '
+ 'ExclusionConstraint.expressions.',
+ category=RemovedInDjango50Warning,
+ stacklevel=2,
+ )
super().__init__(name=name)
def _get_expressions(self, schema_editor, query):