Fix join promotion in disjunction cases
|Reported by:||akaariai||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The current join promotion logic in disjuction cases is confusing, and it produces often too many LEFT joins.
I'd like to clean it up with something like this. There are two commits, one doing the cleanup in sql/query.py, the other adds tests. 4/6 of the added tests fail on master.