Unify subquery generation in the ORM
|Reported by:||Anssi Kääriäinen||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by )
There are some different ways for doing subqueries in the ORM currently.
Query.split_exclude(), subqueries in deletion,
SubqueryConstraint seem to do something similar. Sometimes there are duplicated code paths, sometimes upper layers do something the lower layers will repeat later on.
I think every instance where a subquery constraint is needed should use the
SubqueryConstraint class either directly, or through
sql.Query.build_filter(). This will allow doing all the somewhat complicated setup in one place.