#25693: Data loss if a ManyToManyField is shadowed by Prefetch
-------------------------------------+-------------------------------------
     Reporter:  Ian-Foote            |                    Owner:  Ian-Foote
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by aaugustin):

 * severity:  Normal => Release blocker
 * stage:  Unreviewed => Accepted


Comment:

 I think these are different issues.

 ----

 #21584 demonstrates getting an object, prefetching related objects,
 creating an additional related object: the list of prefetched related
 objects isn't refreshed automatically. (The description makes it look more
 complicated than it actually is.)

 That's because parent.children_set is just a queryset. It's consistent
 with how querysets have always been working. There is exactly the same
 behavior without `prefetech_related`, with any queryset for which the
 results have been fetched.

 The DRF issue Tom mentions is probably a consequence of this. I believe
 DRF should refetch data that may have been invalidated by the updates
 before serializing its response.

 ----

 Now, this bug appears to be much worse becase incorrect data gets written
 back to the database (if I understand correctly).

 Ian, do you know since which version of Django it occurs? I'm wondering if
 we can but controls in place to avoid assigning prefetched querysets to
 writable descriptors or preventing the write from occurring...

--
Ticket URL: <https://code.djangoproject.com/ticket/25693#comment:5>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.6245adbbf141281b7fd711638f1cc6b7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to