#23370: defer() with inherited models fails
----------------------------------------------+--------------------
     Reporter:  dfunckt                       |      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
----------------------------------------------+--------------------
 Let's say I have two models: {{{Post(models.Model)}}} and
 {{{Article(Post)}}} and some data.

 Now if I evaluate the query set
 {{{Post.objects.select_related('article').defer('article__somefield')}}}
 it will fail with:

 {{{
 ...
   File "django/db/models/query.py", line 1457, in get_cached_row
     if (fields[pk_idx] is None or
 IndexError: tuple index out of range

 }}}

 This prevents us from using {{{defer()}}} to optimise our queries to defer
 loading of large TEXT fields when showing lists of posts.

 This is present in master [a81af7f49de7ff3f51f111de28ed3a682f67ea89] and
 (with a similar traceback) since at least Django 1.6.

 I have attached a test project that demonstrates the bug. Add the project
 to path and run:

 {{{
 $ ./manage.py migrate
 $ ./manage.py testdefer
 }}}

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

Reply via email to