diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-05-12 20:10:55 +0200 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-05-14 10:34:30 +0200 |
| commit | f030236a86a64a4befd3cc8093e2bbeceef52a31 (patch) | |
| tree | 170718dd1a0685ee154ea7f6e3a52cae998a6062 /tests/expressions | |
| parent | ceaf1e2848583ba832cc74715da38c802b6b0671 (diff) | |
Fixed #35275 -- Fixed Meta.constraints validation crash on UniqueConstraint with OpClass().
This also introduces Expression.constraint_validation_compatible that
allows specifying that expression should be ignored during a constraint
validation.
Diffstat (limited to 'tests/expressions')
| -rw-r--r-- | tests/expressions/tests.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index f7233305a7..3538900092 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1425,6 +1425,16 @@ class SimpleExpressionTests(SimpleTestCase): hash(Expression(TestModel._meta.get_field("other_field"))), ) + def test_get_expression_for_validation_only_one_source_expression(self): + expression = Expression() + expression.constraint_validation_compatible = False + msg = ( + "Expressions with constraint_validation_compatible set to False must have " + "only one source expression." + ) + with self.assertRaisesMessage(ValueError, msg): + expression.get_expression_for_validation() + class ExpressionsNumericTests(TestCase): @classmethod |
