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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user