#18816: Remove "trim" argument from add_filter()
----------------------------------------------+--------------------
Reporter: akaariai | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
The sql.query.Query.split_exclude() needs to trim one final join when it
adds filters to the original query. It does this by passing "trim" to
add_filter(), and add_filter() then knows to trim the last join.
We can likely directly trim the last part of the join path in
split_exclude() directly. This will remove the need to burden the
add_filter() with the trim argument, and thus makes the ORM code easier to
follow.
The patch in https://github.com/akaariai/django/tree/remove_trim is not
commit ready. There are two problems in need of an answer:
- is the unconditional use of `"pk__in"` as the lookup in case there
were just one lookup part in the path correct? It seems the pk would need
to be changed to something else in case there is a to_field argument for
the relation used.
- removing the trim argument from add_filter() will result in allow_m2m
value being different when add_filter() is called from split_exclude().
For the above reasons: while tests pass with the above patch, I don't
think it is correct.
The removal of trim arg would also maybe make it possible to remove the
current trim_joins() altogether when combined with the patch from #10790,
and this in turn would allow to change the return value from setup_joins()
to something nicer. So, this is one more part in trying to clean the ORM.
--
Ticket URL: <https://code.djangoproject.com/ticket/18816>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.