#25811: Error querying models in different databases in one queryset
-------------------------------------+-------------------------------------
Reporter: ebar0n | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: database | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jarshwah):
* version: 1.8 => master
* type: Bug => Cleanup/optimization
Comment:
That would be roughly the right place @ebar0n, but you might want to try
fixing it at a higher level (callers of "as_subquery_condition") if you go
down that route.
My concern here is one of surprise. Users are mostly aware that passing in
a queryset as an `__IN` lookup results in a single query that has a
subquery. It is what we document to happen. If we silently change this
behaviour based on that subquery having to execute on a different
database, then we're going from a potential efficient subquery to a
potential extremely bad query that pulls out thousands/millions rows back
to Django. Erroring in this condition seems like a good idea, so the user
can explicitly wrap the subquery in a list().
Providing a nicer error message with a hint to list() the subquery seems
like the right solution here.
--
Ticket URL: <https://code.djangoproject.com/ticket/25811#comment:8>
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/064.8b4c51ee6336b53b19e2048c75e3b7ac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.