summaryrefslogtreecommitdiff
path: root/django/db/models/sql/where.py
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-05-27 11:29:43 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2013-05-27 12:25:29 +0300
commitd467e117856a7fa6da5e90471144aaa82d822065 (patch)
tree317cbe65e80dd5260e4b47526ba6f6ad15252144 /django/db/models/sql/where.py
parentae71e3134e87e4cb1631c4d85462ee76116774db (diff)
Fixed #20507 -- SubqueryConstraint alias relabeling
The SubqueryConstraint defined relabeled_clone(), but that was never called. Instead there is now clone() and relabel_aliases() methods for SubqueryConstraint. A related problem was that SubqueryConstraint didn't correctly use quote_name_unless_alias() of the outer query. This resulted in failures when running under PostgreSQL.
Diffstat (limited to 'django/db/models/sql/where.py')
-rw-r--r--django/db/models/sql/where.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 08f9d6c837..2a342d417a 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -408,9 +408,12 @@ class SubqueryConstraint(object):
query.clear_ordering(True)
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, qn)
- def relabeled_clone(self, relabels):
+ def relabel_aliases(self, change_map):
+ self.alias = change_map.get(self.alias, self.alias)
+
+ def clone(self):
return self.__class__(
- relabels.get(self.alias, self.alias),
- self.columns, self.query_object)
+ self.alias, self.columns, self.targets,
+ self.query_object)