Refs #33342 -- Deprecated ExclusionConstraint.opclasses.

This commit is contained in:
Hannes Ljungberg 2021-12-08 21:28:08 +01:00 committed by Mariusz Felisiak
parent ff225fac1d
commit 59a66f0512
5 changed files with 247 additions and 82 deletions

View file

@ -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):