QuerySet.__and__ does not work for joined queries
|Reported by:||mir@…||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||mattimustang@…, yannvr@…||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
# Who has written a and a2? Reporter.objects.filter(article__id__exact=a1.id) & Reporter.objects.filter(article__id__exact=a2.id)
... this does not work as expected. I've added a patch for the or tests that should make it easy for you to verify this bug.
The underlying problem is that you cannot simply lump together the where conditions in this case. This does only work as long as you don't have joins. Probably using UNION would fix this, but is the overhead tolerable?