diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py
index a6f7b5be85..2b6df7d5f5 100644
|
a
|
b
|
from django.db.models import (
|
| 10 | 10 | F, |
| 11 | 11 | Func, |
| 12 | 12 | IntegerField, |
| | 13 | Model, |
| 13 | 14 | Q, |
| 14 | 15 | UniqueConstraint, |
| 15 | 16 | ) |
| 16 | 17 | from django.db.models.fields.json import KeyTextTransform |
| 17 | 18 | from django.db.models.functions import Cast, Left, Lower |
| 18 | 19 | from django.test import ignore_warnings, modify_settings, skipUnlessDBFeature |
| | 20 | from django.test.utils import isolate_apps |
| 19 | 21 | from django.utils import timezone |
| 20 | 22 | from django.utils.deprecation import RemovedInDjango50Warning |
| 21 | 23 | |
| … |
… |
class ExclusionConstraintTests(PostgreSQLTestCase):
|
| 1151 | 1153 | editor.add_constraint(Room, constraint) |
| 1152 | 1154 | self.assertIn(constraint_name, self.get_constraints(Room._meta.db_table)) |
| 1153 | 1155 | |
| | 1156 | @isolate_apps("postgres_tests") |
| | 1157 | def test_table_create(self): |
| | 1158 | constraint_name = "exclusion_equal_number_tc" |
| | 1159 | |
| | 1160 | class ModelWithExclusionConstraint(Model): |
| | 1161 | number = IntegerField() |
| | 1162 | |
| | 1163 | class Meta: |
| | 1164 | app_label = "postgres_tests" |
| | 1165 | constraints = [ |
| | 1166 | ExclusionConstraint( |
| | 1167 | name=constraint_name, |
| | 1168 | expressions=[("number", RangeOperators.EQUAL)], |
| | 1169 | ) |
| | 1170 | ] |
| | 1171 | |
| | 1172 | with connection.schema_editor() as editor: |
| | 1173 | editor.create_model(ModelWithExclusionConstraint) |
| | 1174 | self.assertIn( |
| | 1175 | constraint_name, |
| | 1176 | self.get_constraints(ModelWithExclusionConstraint._meta.db_table), |
| | 1177 | ) |
| | 1178 | |
| 1154 | 1179 | |
| 1155 | 1180 | @modify_settings(INSTALLED_APPS={"append": "django.contrib.postgres"}) |
| 1156 | 1181 | class ExclusionConstraintOpclassesDepracationTests(PostgreSQLTestCase): |