Opened 4 years ago

Last modified 14 months ago

#20127 new Cleanup/optimization

Unify subquery generation in the ORM

Reported by: Anssi Kääriäinen Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

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.

Change History (2)

comment:1 Changed 4 years ago by Anssi Kääriäinen

Triage Stage: UnreviewedAccepted

comment:2 Changed 14 months ago by Tim Graham

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top