mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Refs #30727 -- Added tests for Subquery with queryset in kwargs pickle without evaluating it.
This commit is contained in:
parent
5af17babb0
commit
b739f2e91d
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user