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