mirror of
https://github.com/django/django.git
synced 2025-07-12 07:45:11 +00:00
Fixed #34205 -- Fixed Meta.constraints validation crash with ArrayField and __len lookup.
Regression in 88fc9e2826
that began
manifesting in Django 4.1.
This commit is contained in:
parent
b8738aea14
commit
c5ed884eab
4 changed files with 16 additions and 2 deletions
|
@ -76,6 +76,16 @@ class SchemaTests(PostgreSQLTestCase):
|
|||
constraint.validate(IntegerArrayModel, IntegerArrayModel())
|
||||
constraint.validate(IntegerArrayModel, IntegerArrayModel(field=[1]))
|
||||
|
||||
def test_check_constraint_array_length(self):
|
||||
constraint = CheckConstraint(
|
||||
check=Q(field__len=1),
|
||||
name="array_length",
|
||||
)
|
||||
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…
Add table
Add a link
Reference in a new issue