#23518: Subquery does not respect explicit __exact
-------------------------------------+-------------------------------------
Reporter: john-parton | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 1.7
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: subquery subselect | Unreviewed
exact | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Comment (by tchaumeny):
It looks like the ORM automatically considers that you are doing an `__in`
lookup when you give a `QuerySet` as the right-hand side of a filter on a
related field (see
https://github.com/django/django/blob/bbc3505ef81768aa2afac8f73e6d45b5e8000c55/django/db/models/fields/related.py#L1607).
For instance:
{{{
Author.objects.filter(item__startswith=Item.objects.all())
[<Author: a1>, <Author: a2>, <Author: a2>, <Author: a4>]
}}}
Maybe it would be more consistent if the ORM raised some error instead ?
That being said, I agree that `.get()` is better when you expect a single
result.
--
Ticket URL: <https://code.djangoproject.com/ticket/23518#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 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/069.720d593f48016cf3cde98e89735c411b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.