summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/constraints.py
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-12 13:20:08 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-17 11:49:15 +0100
commit23ec318988cb22bef176b9d81e4091715a4f41ff (patch)
tree6663ee059eb179ef78c13c6ed545ec36014dc253 /django/contrib/postgres/constraints.py
parent5c10041f4636c3dfe637924ab24da85dd657d790 (diff)
downloaddjango-23ec318988cb22bef176b9d81e4091715a4f41ff.tar.gz
Refs #33342 -- Removed ExclusionConstraint.opclasses per deprecation timeline.
Diffstat (limited to 'django/contrib/postgres/constraints.py')
-rw-r--r--django/contrib/postgres/constraints.py31
1 files changed, 1 insertions, 30 deletions
diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py
index 1caf432d16..4c739b3fbb 100644
--- a/django/contrib/postgres/constraints.py
+++ b/django/contrib/postgres/constraints.py
@@ -1,5 +1,3 @@
-import warnings
-
from django.contrib.postgres.indexes import OpClass
from django.core.exceptions import ValidationError
from django.db import DEFAULT_DB_ALIAS, NotSupportedError
@@ -9,7 +7,6 @@ from django.db.models.expressions import Exists, ExpressionList
from django.db.models.indexes import IndexExpression
from django.db.models.lookups import PostgresOperatorLookup
from django.db.models.sql import Query
-from django.utils.deprecation import RemovedInDjango50Warning
__all__ = ["ExclusionConstraint"]
@@ -33,7 +30,6 @@ class ExclusionConstraint(BaseConstraint):
condition=None,
deferrable=None,
include=None,
- opclasses=(),
violation_error_message=None,
):
if index_type and index_type.lower() not in {"gist", "spgist"}:
@@ -57,28 +53,11 @@ class ExclusionConstraint(BaseConstraint):
)
if not isinstance(include, (type(None), list, tuple)):
raise ValueError("ExclusionConstraint.include must be a list or tuple.")
- if not isinstance(opclasses, (list, tuple)):
- raise ValueError("ExclusionConstraint.opclasses must be a list or tuple.")
- if opclasses and len(expressions) != len(opclasses):
- raise ValueError(
- "ExclusionConstraint.expressions and "
- "ExclusionConstraint.opclasses must have the same number of "
- "elements."
- )
self.expressions = expressions
self.index_type = index_type or "GIST"
self.condition = condition
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, violation_error_message=violation_error_message)
def _get_expressions(self, schema_editor, query):
@@ -86,10 +65,6 @@ class ExclusionConstraint(BaseConstraint):
for idx, (expression, operator) in enumerate(self.expressions):
if isinstance(expression, str):
expression = F(expression)
- try:
- expression = OpClass(expression, self.opclasses[idx])
- except IndexError:
- pass
expression = ExclusionConstraintExpression(expression, operator=operator)
expression.set_wrapper_classes(schema_editor.connection)
expressions.append(expression)
@@ -161,8 +136,6 @@ class ExclusionConstraint(BaseConstraint):
kwargs["deferrable"] = self.deferrable
if self.include:
kwargs["include"] = self.include
- if self.opclasses:
- kwargs["opclasses"] = self.opclasses
return path, args, kwargs
def __eq__(self, other):
@@ -174,13 +147,12 @@ class ExclusionConstraint(BaseConstraint):
and self.condition == other.condition
and self.deferrable == other.deferrable
and self.include == other.include
- and self.opclasses == other.opclasses
and self.violation_error_message == other.violation_error_message
)
return super().__eq__(other)
def __repr__(self):
- return "<%s: index_type=%s expressions=%s name=%s%s%s%s%s>" % (
+ return "<%s: index_type=%s expressions=%s name=%s%s%s%s>" % (
self.__class__.__qualname__,
repr(self.index_type),
repr(self.expressions),
@@ -188,7 +160,6 @@ class ExclusionConstraint(BaseConstraint):
"" if self.condition is None else " condition=%s" % self.condition,
"" if self.deferrable is None else " deferrable=%r" % self.deferrable,
"" if not self.include else " include=%s" % repr(self.include),
- "" if not self.opclasses else " opclasses=%s" % repr(self.opclasses),
)
def validate(self, model, instance, exclude=None, using=DEFAULT_DB_ALIAS):