#29545: Nested OuterRef not looking on the right model for the field.
     Reporter:  Aaron Lisman         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  outerref, subquery   |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
Changes (by Can Sarıgöl):

 * cc: Can Sarıgöl (added)


 IMO this query join order should be like this:

 inner = Item.objects.filter(

 middle = Invoice.objects.filter(

 outer = Item.objects.filter(

 If you want to use nested outerref, middle query has to contain foreign
 keys. Otherwise, this usage needs to include deep related field.

 middle = Item.objects.filter(invoices=OuterRef('id'),).annotate(

 or maybe not necessary nested outerref

 inner = Invoice.objects.filter(

Ticket URL: <https://code.djangoproject.com/ticket/29545#comment:3>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to