mirror of
https://github.com/django/django.git
synced 2025-10-06 00:30:37 +00:00
[4.1.x] Fixed #34205 -- Fixed Meta.constraints validation crash with ArrayField and __len lookup.
Regression in88fc9e2826
that began manifesting in Django 4.1. Backport ofc5ed884eab
from main.
This commit is contained in:
parent
3137174344
commit
af3cfc8630
4 changed files with 16 additions and 2 deletions
|
@ -67,6 +67,16 @@ class SchemaTests(PostgreSQLTestCase):
|
|||
RangesModel.objects.create(ints=(20, 50))
|
||||
RangesModel.objects.create(ints=(10, 30))
|
||||
|
||||
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