diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py index baf2e96aaf..a58e45caed 100644 --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -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)