#17665: Inconsitent behaviour of filter() with multi-valued relations.
-------------------------------------+-------------------------------------
Reporter: lrekucki | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 1.3
layer (models, ORM) | Keywords:
Severity: Normal | Has patch: 0
Triage Stage: | Needs tests: 0
Unreviewed | Easy pickings: 0
Needs documentation: 0 |
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
This is probably a duplicate as I recall seeing a similar issue, but I
couldn't find it, so here it goes:
We have 2 models (lets say, Company and Person), connected thru a M2M
table (Membership) with additional attribute "active".
The following queries work as documented:
{{{
base = Company.objects.all()
# 1) select all companies in which person 1 is active
base.filter(membership_set__active=True, membership_set__person=1)
# 2) select all companies in which some membership is active or person '1'
is a member
base.filter(membership_set__active=True).filter(membership_set__person=1)
}}}
But if you apply the {{{filter()}} directly to the manager:
{{{Company.objects.filter(membership_set__active=True,
membership_set__person=1)}}}
The behaviour is the same as query 2), while it should work like 1).
--
Ticket URL: <https://code.djangoproject.com/ticket/17665>
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 this group at
http://groups.google.com/group/django-updates?hl=en.