Opened 13 years ago
Closed 13 years ago
#17315 closed Bug (duplicate)
.exclude(a, b) does not operate on a single related record
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I'm not sure if this is an implementation error, or a documentation error, but according to the documentation for filter/exclude spanning multi-valued relationships[1]:
"Everything inside a single filter() call is applied simultaneously to filter out items matching all those requirements. Successive filter() calls further restrict the set of objects, but for multi-valued relations, they apply to any object linked to the primary model, not necessarily those objects that were selected by an earlier filter() call."
"All of this behavior also applies to exclude(): all the conditions in a single exclude() statement apply to a single instance (if those conditions are talking about the same multi-valued relation)"
yet I can create a test [2] which seems to show this is not the case. The filter seems to do the correct thing, but the .exclude() call applies multiple args inside the call to separate instances [3]
[1] https://docs.djangoproject.com/en/dev/topics/db/queries/#spanning-multi-valued-relationships
[2] http://paste.ubuntu.com/754721/ which, when run, results in http://paste.ubuntu.com/754723/
[3] http://paste.ubuntu.com/754742/
Attachments (1)
Change History (2)
by , 13 years ago
Attachment: | django-exclude-bug.diff added |
---|
comment:1 by , 13 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Yes, these tests show that the generated SQL doesn't match the documentation.
I believe this problem was already reported in #14645.
Diff adding failing test