mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
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.
This commit is contained in:
committed by
Sarah Boyce
parent
ceaf1e2848
commit
f030236a86
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user