{{{
def test_pickle_prefetch_related_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 QS
with self.assertNumQueries(0):
pickle.dumps(groups)
}}}
At current doing `pickle.dumps` evaluates `Event.objects.order_by('id')`
which is obviously a bad thing, especially if `Event` is a large table!
Found this as a kind of regression when upgrading 1.9 -> 1.10 because the
`prefetch_related` refactoring seems to be keeping the `Prefetch` objects
around more, but afaict it has always existed.
--
Ticket URL: <https://code.djangoproject.com/ticket/27499>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: Uncategorized => Bug
--
Ticket URL: <https://code.djangoproject.com/ticket/27499#comment:1>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/7567
--
Ticket URL: <https://code.djangoproject.com/ticket/27499#comment:2>
* component: Uncategorized => Database layer (models, ORM)
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/27499#comment:3>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/27499#comment:4>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"e044026dce063ec53c16d0f755ec75eb8c84b318" e044026d]:
{{{
#!CommitTicketReference repository=""
revision="e044026dce063ec53c16d0f755ec75eb8c84b318"
Fixed #27499 -- Made Prefetches pickle without evaluating their QuerySet.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/27499#comment:5>