1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #27499 -- Made Prefetches pickle without evaluating their QuerySet.

This commit is contained in:
Adam Chainz
2016-11-16 14:49:20 +00:00
committed by Tim Graham
parent 7dd315a46f
commit e044026dce
2 changed files with 19 additions and 0 deletions

View File

@@ -134,6 +134,15 @@ class PickleabilityTestCase(TestCase):
groups2 = pickle.loads(pickle.dumps(groups))
self.assertSequenceEqual(groups2.filter(id__gte=0), [g])
def test_pickle_prefetch_queryset_not_evaluated(self):
Group.objects.create(name='foo')
groups = Group.objects.prefetch_related(
models.Prefetch('event_set', queryset=Event.objects.order_by('id'))
)
list(groups) # evaluate QuerySet
with self.assertNumQueries(0):
pickle.loads(pickle.dumps(groups))
def test_pickle_prefetch_related_with_m2m_and_objects_deletion(self):
"""
#24831 -- Cached properties on ManyToOneRel created in QuerySet.delete()