#26801: Queryset gets corrupted when using nested Prefetch
----------------------------------------------+----------------------------
     Reporter:  mlubimow                      |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.8
     Severity:  Normal                        |   Keywords:  prefetch,
                                              |  queryset
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+----------------------------
 When queryset objects contains nested Prefetch objects, after first
 evaluation it gets corrupted.

 Im attaching simple example, to reproduce a bug you need to run these
 commands:

 1. Install requirements file
 2. python mange.py migrate
 3. python manage runserver

 Open your browser on:

 http://127.0.0.1:8000/

 And refresh '''twice'''. First time its gonna work, next time you should
 get an error:


 {{{
 AttributeError at /
 Cannot find 'author' on UserProfile object, 'author__profile__university'
 is an invalid parameter to prefetch_related()
 }}}


 From my limited investigation it looks like after first evaluation
 prefetch_to parameter is prepended with previous prefetch_to param, which
 is in this case not correct.

 Temporarly, its enough to create this object (queryset) again every time
 it gets used.

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

Reply via email to