#29271: Chaining Filters on a Reverse Foreign Key Produces Multiple Joins
-------------------------------------+-------------------------------------
Reporter: Michael MacIntosh | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: filter chain | Triage Stage: Accepted
reverse foreign key |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Andrew Standley):
I'm pretty sure it's a good rule of thumb that when the behaviour of a
feature is highly unintuitive, one should question whether it was a good
design choice. I'll take this to the mailing list in the hope someone can
explain the justification for this intended behaviour because ,to my naive
self, it seems that `Q` objects would be a cleaner way to allow the type
of multi-valued queries referenced in
[https://docs.djangoproject.com/en/dev/topics/db/queries/#spanning-multi-
valued-relationships spanning multi-valued relationships].
I would argue that regardless, this is an issue with the documentation as
Simon suggests.
The [https://docs.djangoproject.com/en/2.0/ref/models/querysets/#filter
filter] documentation simply states that filters are joined via AND.
Meanwhile the [https://docs.djangoproject.com/en/2.0/topics/db/queries
/#chaining-filters chaining filters] documentation explicitly states that
successive filters act on the result of the last filter. Neither have any
link or reference to the contradictory behaviour documented in
[https://docs.djangoproject.com/en/dev/topics/db/queries/#spanning-multi-
valued-relationships spanning multi-valued relationships]
--
Ticket URL: <https://code.djangoproject.com/ticket/29271#comment:4>
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/071.f7bd2839714310ec8cc6556385b0095b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.