1
0
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:
Tim Martin
2017-11-05 21:34:02 +00:00
committed by Tim Graham
parent 6deaddcca3
commit 5778b5701d
2 changed files with 7 additions and 0 deletions

View File

@@ -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))