#31922: QuerySet.filter() against Q() with Subquery() and __in produces wrong
results.
-------------------------------------+-------------------------------------
Reporter: Chris Bell | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: orm, subquery, q, | Triage Stage: Accepted
order |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):
* version: 2.2 => master
* stage: Unreviewed => Accepted
Comment:
Thanks for the detailed report, I was able to reproduce this issue.
Everything works properly with `Exists()`:
{{{
>>> q1_exists = Exists(BookStatus.objects.filter(status='DRAFT',
book__id=OuterRef('pk')))
>>> q2_exists = ~Exists(BookStatus.objects.filter(status='PUBLISHED',
book__id=OuterRef('pk')))
>>> Book.objects.filter(q2_exists & q1_exists)
<QuerySet [<Book: Book object (2)>]>
>>> Book.objects.filter(q1_exists & q2_exists)
<QuerySet [<Book: Book object (2)>]>
}}}
Reproduced at 41725602afebe2ddb018b99afe134384cc3bf69e.
--
Ticket URL: <https://code.djangoproject.com/ticket/31922#comment:2>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.76686aa577fb0af308a3d300e0448c04%40djangoproject.com.