Comment (by Adam (Chainz) Johnson):
I had a brief look at fixing this. I think it's possible by filtering the
objects before trying to prefetch for them. See
https://github.com/adamchainz/django/commit/bc2991c0908abbf4973cbb4850ffff0dea4bbd6f
. This currently fails three prefetch tests - one for executing an extra
query, two for executing one fewer query (which may actually represent a
true optimization).
--
Ticket URL: <https://code.djangoproject.com/ticket/32089#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => AlexeyNigin
* status: new => assigned
Comment:
Hello! I would like to work on this ticket to complete a requirement for
the final project in my software engineering class
(https://web.eecs.umich.edu/~weimerw/481/hw6.html). Since this is my first
time contributing to Django, it might take me some time to make progress
on this ticket. Thank you for your patience, and if you need to fix this
ticket urgently in the meantime, feel free to unassign me from it.
--
Ticket URL: <https://code.djangoproject.com/ticket/32089#comment:8>
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/13774
I modified Adam Johnson's patch so that it doesn't fail any of the
prefetch tests, and added a minimized version of Dennis Kliban's test for
regression. Would appreciate a review!
--
Ticket URL: <https://code.djangoproject.com/ticket/32089#comment:9>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32089#comment:10>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"b9ba85a7ce582f4821a21119a6c130dacab496c4" b9ba85a]:
{{{
#!CommitTicketReference repository=""
revision="b9ba85a7ce582f4821a21119a6c130dacab496c4"
Fixed #32089 -- Fixed prefetch_related_objects() when some objects are
already fetched.
Thanks Dennis Kliban for the report and Adam Johnson for the initial
patch.
Co-authored-by: Adam Johnson <m...@adamj.eu>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32089#comment:11>