#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 charettes):
* cc: charettes (added)
Comment:
This issue also recently surfaced on the
[https://groups.google.com/d/topic/django-users/CDe4McxxCsI/discussion
django-users mailing list].
> Now, this bug appears to be much worse becase incorrect data gets
written back to the database (if I understand correctly).
You do.
> 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...
This bug exists since the introduction of the `Prefetch` object (Django
1.7).
> This seems related to #25550. Would a backport fix this bug?
The ticket is related but the issue will remain until the assignment is
actually removed. It's currently only pending deprecation on `master`.
Since we'll have to live with this assignment issue until 2.0 the only
viable solution I can think of at the moment would be to raise a
`ValueError` if `getattr(queryset.model, to_attr)` is an instance of one
of the problematic descriptors.
--
Ticket URL: <https://code.djangoproject.com/ticket/25693#comment:8>
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.7b6b75a2f9dfd630bd1ce0d5ef15da65%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.