From 9c4882b391157f6aa3c0ade309638ffcd3bdf684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Sun, 24 Mar 2013 22:55:30 +0200 Subject: [PATCH] Fixed Oracle specific failures in multicolumn joins Refs #19385 --- django/db/models/sql/where.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py index c738c914d12..029226383de 100644 --- a/django/db/models/sql/where.py +++ b/django/db/models/sql/where.py @@ -395,10 +395,10 @@ class SubqueryConstraint(object): # QuerySet was sent if hasattr(query, 'values'): - # as_sql should throw if we are using a - # connection on another database - query._as_sql(connection=connection) + if query._db and connection.alias != query._db: + raise ValueError("Can't do subqueries with queries on different DBs.") query = query.values(*self.targets).query + query.clear_ordering(True) query_compiler = query.get_compiler(connection=connection) return query_compiler.as_subquery_condition(self.alias, self.columns)