#25693: Data loss if a ManyToManyField is shadowed by Prefetch
----------------------------------------------+--------------------
     Reporter:  Ian-Foote                     |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  master
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 With two models:

 {{{#!python
 class Book(Model):
     name = CharField(max_length=100)

 class Author(Model):
     books = ManyToManyField(Book)
 }}}

 it is possible to create a prefetch query that loses data from
 Author.books:

 {{{#!python
 poems = Book.objects.filter(name='Poems')
 Author.objects.prefetch_related(
     Prefetch('books', queryset=poems, to_attr='books'),
 )
 }}}

 When this queryset is evaluated, each Author's books is overridden by the
 poems queryset.

--
Ticket URL: <https://code.djangoproject.com/ticket/25693>
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/052.bc74862b018696d93c7d19edf6c77072%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to