1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #25811 -- Added a helpful error when making _in queries across different databases.

This commit is contained in:
Edwar Baron
2016-02-25 23:32:43 -04:30
committed by Tim Graham
parent 7fec264e46
commit eb44172760
2 changed files with 15 additions and 0 deletions

View File

@@ -203,6 +203,13 @@ class In(BuiltinLookup):
lookup_name = 'in'
def process_rhs(self, compiler, connection):
db_rhs = getattr(self.rhs, '_db', None)
if db_rhs is not None and db_rhs != connection.alias:
raise ValueError(
"Subqueries aren't allowed across different databases. Force "
"the inner query to be evaluated using `list(inner_query)`."
)
if self.rhs_is_direct_value():
try:
rhs = set(self.rhs)