#25298: Forbid QuerySet filtering by a related field that expects a single value
when multiple values are returned
-------------------------------------+-------------------------------------
Reporter: timgraham | Owner: Y3K
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by akaariai):
Notably
`Foo.objects.filter(related_model__exact=RelatedModel.objects.values('pk'))`
should work when the RelatedModel query returns just a single row. This is
a completely valid query, equivalent to:
{{{
SELECT ... FROM foo WHERE related_model_id = (SELECT id FROM relatedmodel)
}}}
If the subquery returns one or zero rows, this query should work on all
backends.
--
Ticket URL: <https://code.djangoproject.com/ticket/25298#comment:3>
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/067.d271b0df213d2b0519896c1809a1c0d8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.