Please sign in to comment.
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.
- Loading branch information...
Showing with 246 additions and 57 deletions.
|@@ -0,0 +1,28 @@|
|+from django.db import models|
|+ name = models.CharField(max_length=200)|
|+ title = models.CharField(max_length=200)|
|+ director = models.ForeignKey(Person)|
|+ movie = models.ForeignKey(Movie)|
|+ movie = models.ForeignKey(Movie, null=True)|
|+ screening = models.ForeignKey(Screening, null=True)|
|+ screening = models.ForeignKey(ScreeningNullFK, null=True)|
Oops, something went wrong.