summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHannes Ljungberg <hannes@5monkeys.se>2020-06-29 06:41:23 +0200
committerGitHub <noreply@github.com>2020-06-29 06:41:23 +0200
commit30e3d2d78df01d5e89e8a9491f5f061dda239fe5 (patch)
tree6262ea7e260bce213626d5da98edcb34a0c919f2 /tests
parent62d85a283500e9abb0e1c9ec53c59be468f056a0 (diff)
Fixed #31745 -- Added error messages when using UniqueConstraint.include/opclasses with deferrable.
Diffstat (limited to 'tests')
-rw-r--r--tests/constraints/tests.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py
index 4ec1f2a8e8..d9e91bdf49 100644
--- a/tests/constraints/tests.py
+++ b/tests/constraints/tests.py
@@ -406,6 +406,26 @@ class UniqueConstraintTests(TestCase):
deferrable=models.Deferrable.DEFERRED,
)
+ def test_deferrable_with_include(self):
+ message = 'UniqueConstraint with include fields cannot be deferred.'
+ with self.assertRaisesMessage(ValueError, message):
+ models.UniqueConstraint(
+ fields=['name'],
+ name='name_inc_color_color_unique',
+ include=['color'],
+ deferrable=models.Deferrable.DEFERRED,
+ )
+
+ def test_deferrable_with_opclasses(self):
+ message = 'UniqueConstraint with opclasses cannot be deferred.'
+ with self.assertRaisesMessage(ValueError, message):
+ models.UniqueConstraint(
+ fields=['name'],
+ name='name_text_pattern_ops_unique',
+ opclasses=['text_pattern_ops'],
+ deferrable=models.Deferrable.DEFERRED,
+ )
+
def test_invalid_defer_argument(self):
message = 'UniqueConstraint.deferrable must be a Deferrable instance.'
with self.assertRaisesMessage(ValueError, message):