mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #33895 -- Fixed Case() crash with filters that match everything in When().
Thanks shukryzablah for the report.
This commit is contained in:
committed by
Mariusz Felisiak
parent
63884829ac
commit
036bb2b74a
@@ -415,6 +415,16 @@ class CaseExpressionTests(TestCase):
|
||||
self.assertEqual(len(objects), CaseTestModel.objects.count())
|
||||
self.assertTrue(all(obj.selected == "not selected" for obj in objects))
|
||||
|
||||
def test_annotate_with_full_when(self):
|
||||
objects = CaseTestModel.objects.annotate(
|
||||
selected=Case(
|
||||
When(~Q(pk__in=[]), then=Value("selected")),
|
||||
default=Value("not selected"),
|
||||
)
|
||||
)
|
||||
self.assertEqual(len(objects), CaseTestModel.objects.count())
|
||||
self.assertTrue(all(obj.selected == "selected" for obj in objects))
|
||||
|
||||
def test_combined_expression(self):
|
||||
self.assertQuerysetEqual(
|
||||
CaseTestModel.objects.annotate(
|
||||
|
||||
Reference in New Issue
Block a user