Django ORM transforming inner join to outer joins depending on Q() ordering
|Reported by:||djcoin||Owned by:||nobody|
|Severity:||Normal||Keywords:||orm, outer join, inner join, join, Q, filter|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I don't have the time yet to completely isolate the bug/reproducing steps, yet im almost sure there is a bug related to this.
You may see sql log files attached as changes are performed to my code an thus query hit the postgres database.
I created a more or less complex queryset.
I have to Q filter to apply to it: say Q1 and Q2.
Filtering by the one or the other not at the same time yields results.
But when both are combined with an or, Q1 | Q2, results changes.
In one case I do not have any result in the other I have.
Printing postgres log, it seems that in one case, some joins are made inner (no results then) in the other case, outer joins are made.
Summary: difference between the two below request (inner join to outer join):
queryset = queryset.filter(event_descr_filter | op_filter)
queryset = queryset.filter(op_filter | event_descr_filter)
See all the files attached.
You wont be able to reproduce the bug, but it may gives you clues.