Fix invalid INNER JOIN added on LEFT OUTER JOIN for django 5.2#130
Conversation
The invalid INNER JOIN was generated for another relation that is used within the join condition, which incorrectly reduces the result set.
millerdev
left a comment
There was a problem hiding this comment.
Could this change behavior in a backward-incompatible way for CTE joins that used LOUTER?
|
It could... LEFT OUTER JOINs such as the one from the new test case return more result rows after this fix. However, I would say that the new behavior is the correct one, since it aligns with the behavior of LEFT OUTER JOINs directly on the db: the left outer join always includes all rows from the left side in the join result set. With the fix, django-cte would align with this behavior even if the join condition requires implicit joining of an additional third relation table. The previous query (as before the fix) can be achieved e.g. by additionally adding an |
|
Using |
The issue also affects previous Django versions, but for Django 5.2 there is this fix. I'm also unsure about bumping the major version.
See PR #131. |
Update CHANGELOG with breaking change from PR #130
The invalid INNER JOIN was generated for another relation that is used within the join condition, which incorrectly reduces the result set. With Django 5.2 the issue can be fixed by only updating the join types if the CTE join is an INNER JOIN.