mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +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:
parent
ceaf1e2848
commit
f030236a86
8 changed files with 61 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue