Refs -- Added tests for Subquery with queryset in kwargs pickle without evaluating it.
@@ -195,6 +195,18 @@ class PickleabilityTestCase(TestCase):
with self.assertNumQueries(0):
self.assert_pickles(groups)
+ def test_pickle_exists_kwargs_queryset_not_evaluated(self):
+ group = Group.objects.create(name='group')
+ Event.objects.create(title='event', group=group)
+ groups = Group.objects.annotate(
+ has_event=models.Exists(
+ queryset=Event.objects.filter(group_id=models.OuterRef('id')),
+ ),
+ )
+ list(groups) # evaluate QuerySet.
+ with self.assertNumQueries(0):
+ self.assert_pickles(groups)
+
def test_pickle_subquery_queryset_not_evaluated(self):
group = Group.objects.create(name='group')
Event.objects.create(title='event', group=group)
