mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Refs #33905 -- Added test for CheckConstraint() validation with ArrayField and __contains.
This commit is contained in:
parent
cccfb45d00
commit
e0ac72fe80
@ -65,6 +65,16 @@ class SchemaTests(PostgreSQLTestCase):
|
||||
RangesModel.objects.create(ints=(20, 50))
|
||||
RangesModel.objects.create(ints=(10, 30))
|
||||
|
||||
def test_check_constraint_array_contains(self):
|
||||
constraint = CheckConstraint(
|
||||
check=Q(field__contains=[1]),
|
||||
name="array_contains",
|
||||
)
|
||||
msg = f"Constraint “{constraint.name}” is violated."
|
||||
with self.assertRaisesMessage(ValidationError, msg):
|
||||
constraint.validate(IntegerArrayModel, IntegerArrayModel())
|
||||
constraint.validate(IntegerArrayModel, IntegerArrayModel(field=[1]))
|
||||
|
||||
def test_check_constraint_daterange_contains(self):
|
||||
constraint_name = "dates_contains"
|
||||
self.assertNotIn(
|
||||
|
Loading…
Reference in New Issue
Block a user