#20127: Unify subquery generation in the ORM
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by timgraham:
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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.9ce6f62eabd84d6bcb772b4db86f5f7e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.