mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #28731 -- Added an error message when using an empty Q() in a When expression.
Otherwise it generates invalid SQL.
This commit is contained in:
@@ -1301,3 +1301,8 @@ class CaseWhenTests(SimpleTestCase):
|
||||
When(condition=object())
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
When()
|
||||
|
||||
def test_empty_q_object(self):
|
||||
msg = "An empty Q() can't be used as a When() condition."
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
When(Q(), then=Value(True))
|
||||
|
||||
Reference in New Issue
Block a user