#16715: Wrong JOIN with nested null-able foreign keys
-------------------------------------+-------------------------------------
     Reporter:  sebastian            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |               Resolution:  fixed
     Severity:  Normal               |             Triage Stage:  Ready for
     Keywords:  join, values,        |  checkin
  nested, foreign key, null-able     |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by Anssi Kääriäinen <akaariai@…>):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [01b9c3d5193fe61b82ae8b26242a13fdec22f211]:
 {{{
 #!CommitTicketReference repository=""
 revision="01b9c3d5193fe61b82ae8b26242a13fdec22f211"
 Fixed #16715 -- Fixed join promotion logic for nested nullable FKs

 The joins for nested nullable foreign keys were often created as INNER
 when they should have been OUTER joins. The reason was that only the
 first join in the chain was promoted correctly. There were also issues
 with select_related etc.

 The basic structure for this problem was:
   A -[nullable]-> B -[nonnull]-> C

 And the basic problem was that the A->B join was correctly LOUTER,
 the B->C join not.

 The major change taken in this patch is that now if we promote a join
 A->B, we will automatically promote joins B->X for all X in the query.
 Also, we now make sure there aren't ever join chains like:
    a LOUTER b INNER c
 If the a -> b needs to be LOUTER, then the INNER at the end of the
 chain will cancel the LOUTER join and we have a broken query.

 Sebastian reported this problem and did also major portions of the
 patch.
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16715#comment:25>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to