From 355c5edd9390caad5725375abca03460805f663b Mon Sep 17 00:00:00 2001 From: Anssi Kääriäinen Date: Thu, 16 Apr 2015 08:39:31 +0300 Subject: Fixed #24605 -- Fixed incorrect reference to alias in subquery. Thanks to charettes and priidukull for investigating the issue, and to kurevin for the report. --- django/db/models/sql/compiler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 1ca56d60f1..b70a15755b 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -347,7 +347,8 @@ class SQLCompiler(object): if name in self.quote_cache: return self.quote_cache[name] if ((name in self.query.alias_map and name not in self.query.table_map) or - name in self.query.extra_select or name in self.query.external_aliases): + name in self.query.extra_select or ( + name in self.query.external_aliases and name not in self.query.table_map)): self.quote_cache[name] = name return name r = self.connection.ops.quote_name(name) -- cgit v1.3