#36385: Simplify implementation of filtering in QuerySet.
-------------------------------------+-------------------------------------
Reporter: Nick Pope | Owner: Nick Pope
Type: | Status: assigned
Cleanup/optimization |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Some of the code for filtering QuerySet is overly complex which makes it
hard to follow:
- Methods that are nearly identical, e.g. `QuerySet._clone()` vs
`QuerySet._chain()` and `Query.clone()` vs `Query.chain()`
- These used to do more, but now are not significantly different such
that they're worth keeping separate.
- Private API like `Queryset.complex_filter()` which exists for a specific
case but can be handled using public APIs
- Flags such as `_defer_next_filter` and `_sticky_filter` that affect the
''next'' call to `QuerySet.filter()`
- Passing around deconstructed pieces instead of building a `Q()` object
as early as possible
- Not using the `klass` argument to `Query.chain()` and altering
`__class__` manually
We should be able to simplify this, removing a number of flag attributes
and methods in the process.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36385>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.