#32511: Deferred fields incorrect when following prefetches back to the "parent"
object
-------------------------------------+-------------------------------------
     Reporter:  Jamie Matthews       |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 When using `prefetch_related` the retrieved objects are assigned their
 origin's foreign object so in this case the inner prefetch is performed
 but entirely discarded because it's the outer's query `user` (the ones
 with ''only'' `email`) that are assigned to the prefetched profiles.

 I guess we should either change the current behaviour to default to using
 the origin's object but allow overrides with nested prefetches as it might
 be useful when dealing with graphs of objects or raise an exception in
 this case to denote this isn't supported.

 I think you'll want to look at this branch of `prefetch_one_level` to
 special case already cached instances
 
https://github.com/django/django/blob/b19041927883123e0147d80b820ddabee9a716f6/django/db/models/query.py#L1905-L1913

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32511#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.ef413563b53850dc1280f95d3430d120%40djangoproject.com.

Reply via email to