diff options
| author | James Gillard <jamesgillard@live.co.uk> | 2022-12-10 15:46:23 +0000 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-12-10 17:46:13 +0100 |
| commit | c5ed884eabf3b2b67581c55bf6c87e721f69157f (patch) | |
| tree | 0d17696247838cdd5a3264bcfd9c80232792d328 /tests/postgres_tests | |
| parent | b8738aea14446b267a47087b52b38a98b440a6aa (diff) | |
Fixed #34205 -- Fixed Meta.constraints validation crash with ArrayField and __len lookup.
Regression in 88fc9e2826044110b7b22577a227f122fe9c1fb5 that began
manifesting in Django 4.1.
Diffstat (limited to 'tests/postgres_tests')
| -rw-r--r-- | tests/postgres_tests/test_constraints.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/postgres_tests/test_constraints.py b/tests/postgres_tests/test_constraints.py index 72e3e66895..9aa5bfdbb8 100644 --- a/tests/postgres_tests/test_constraints.py +++ b/tests/postgres_tests/test_constraints.py @@ -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( |
