I think every instance where a subquery constrain is needed should use the
SubqueryConstraint either directly, or through QuerySet.filter() or
sql.Query.build_filter(). This will allow doing all the somewhat
complicated setup in one place.
--
Ticket URL: <https://code.djangoproject.com/ticket/20127>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/20127#comment:1>
Old description:
> There are some different ways for doing subqueries in the ORM currently.
> Query.split_exclude(), subqueries in deletion, as_nested_sql() and
> 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 constrain is needed should use
> the SubqueryConstraint either directly, or through QuerySet.filter() or
> sql.Query.build_filter(). This will allow doing all the somewhat
> complicated setup in one place.
New description:
There are some different ways for doing subqueries in the ORM currently.
`Query.split_exclude()`, subqueries in deletion, `as_nested_sql()` and
`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
`QuerySet.filter()` or `sql.Query.build_filter()`. This will allow doing
all the somewhat complicated setup in one place.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/20127#comment:2>