mirror of https://github.com/django/django.git
parent
24234555a0
commit
9c4882b391
|
@ -395,10 +395,10 @@ class SubqueryConstraint(object):
|
||||||
|
|
||||||
# QuerySet was sent
|
# QuerySet was sent
|
||||||
if hasattr(query, 'values'):
|
if hasattr(query, 'values'):
|
||||||
# as_sql should throw if we are using a
|
if query._db and connection.alias != query._db:
|
||||||
# connection on another database
|
raise ValueError("Can't do subqueries with queries on different DBs.")
|
||||||
query._as_sql(connection=connection)
|
|
||||||
query = query.values(*self.targets).query
|
query = query.values(*self.targets).query
|
||||||
|
query.clear_ordering(True)
|
||||||
|
|
||||||
query_compiler = query.get_compiler(connection=connection)
|
query_compiler = query.get_compiler(connection=connection)
|
||||||
return query_compiler.as_subquery_condition(self.alias, self.columns)
|
return query_compiler.as_subquery_condition(self.alias, self.columns)
|
||||||
|
|
Loading…
Reference in New Issue