diff options
author | Tim Martin <tim@asymptotic.co.uk> | 2017-11-05 21:34:02 +0000 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-12-26 10:39:47 -0500 |
commit | 5778b5701d6a0feb3053b70891cd8ce80b6e8601 (patch) | |
tree | 7c939b1477d232d2e3fbcf6b1b92d590454e6e3e /tests/expressions_case | |
parent | 6deaddcca367d0143c815aaa42342021baa3b41e (diff) | |
download | django-5778b5701d6a0feb3053b70891cd8ce80b6e8601.tar.gz |
Fixed #28731 -- Added an error message when using an empty Q() in a When expression.
Otherwise it generates invalid SQL.
Diffstat (limited to 'tests/expressions_case')
-rw-r--r-- | tests/expressions_case/tests.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py index 69e299bde9..90aba36031 100644 --- a/tests/expressions_case/tests.py +++ b/tests/expressions_case/tests.py @@ -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)) |