From b739f2e91d68aa3d4c5009127a43af037796225a Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 19 May 2020 21:05:52 +0200 Subject: [PATCH] Refs #30727 -- Added tests for Subquery with queryset in kwargs pickle without evaluating it. --- tests/queryset_pickle/tests.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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)