Comment (by Maxime Toussaint):
So, it makes sense that the order matters, especially for Prefetch with
to_attr, since until it has been fetched, it does not exist yet. Here
though, these are 2 very separate calls to the database that have
absolutely no interaction with each other. Shouldn't they be independent?
It doesn't make sense to me that it works in one order but it does not in
the other. I am vey surprised to hear that such a thing could be the
intended behaviour, as I can't make sense of why it could be. If you could
give more depth to your reasoning, it would be much appreciated.
--
Ticket URL: <https://code.djangoproject.com/ticket/34791#comment:9>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Mariusz Felisiak):
> I am vey surprised to hear that such a thing could be the intended
behaviour, as I can't make sense of why it could be. If you could give
more depth to your reasoning, it would be much appreciated.
I changed my mind and agreed that we should fix it, that's why I accepted
this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/34791#comment:10>
* owner: nobody => Maxime Toussaint
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34791#comment:11>
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/17207
--
Ticket URL: <https://code.djangoproject.com/ticket/34791#comment:12>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/34791#comment:13>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"254df3a3bbc2f4df51f9e2070ab2e214553f67d0" 254df3a]:
{{{
#!CommitTicketReference repository=""
revision="254df3a3bbc2f4df51f9e2070ab2e214553f67d0"
Fixed #34791 -- Fixed incorrect Prefetch()'s cache for singly related
objects.
Changed the cache name used for singly related objects to be the
to_attr parameter passed to a Prefetch object. This fixes issues with
checking if values have already been fetched in cases where the Field
already has some prefetched value, but not for the same model attr.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34791#comment:14>