diff options
| author | Tim Graham <timograham@gmail.com> | 2015-01-29 07:20:56 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-01-30 06:34:36 -0500 |
| commit | df68751134531462f005a75e7342d46540033b88 (patch) | |
| tree | 98ad130e7c5b30f30edeb8fd2d6679cc43d88550 /django/db/models/sql/compiler.py | |
| parent | a301061f88268255fc2660ca993a84b8bf12f9d2 (diff) | |
[1.8.x] Fixed #24164 -- Fixed Oracle GIS limited aggregation test failure.
Backport of 29c0073335c7f7cdc482866e093e5e42a42625e5 from master
Diffstat (limited to 'django/db/models/sql/compiler.py')
| -rw-r--r-- | django/db/models/sql/compiler.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 7944e35d8a..5b647888d1 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -30,6 +30,7 @@ class SQLCompiler(object): self.annotation_col_map = None self.klass_info = None self.ordering_parts = re.compile(r'(.*)\s(ASC|DESC)(.*)') + self.subquery = False def setup_query(self): if all(self.query.alias_refcount[a] == 0 for a in self.query.tables): @@ -342,11 +343,11 @@ class SQLCompiler(object): sql, params = vendor_impl(self, self.connection) else: sql, params = node.as_sql(self, self.connection) - if select_format: + if select_format and not self.subquery: return node.output_field.select_format(self, sql, params) return sql, params - def as_sql(self, with_limits=True, with_col_aliases=False): + def as_sql(self, with_limits=True, with_col_aliases=False, subquery=False): """ Creates the SQL for this query. Returns the SQL string and list of parameters. @@ -359,6 +360,7 @@ class SQLCompiler(object): # However we do not want to get rid of stuff done in pre_sql_setup(), # as the pre_sql_setup will modify query state in a way that forbids # another run of it. + self.subquery = subquery refcounts_before = self.query.alias_refcount.copy() try: extra_select, order_by, group_by = self.pre_sql_setup() @@ -1115,9 +1117,9 @@ class SQLAggregateCompiler(SQLCompiler): raise EmptyResultSet sql, params = [], [] for annotation in self.query.annotation_select.values(): - agg_sql, agg_params = self.compile(annotation) - sql.append(agg_sql) - params.extend(agg_params) + ann_sql, ann_params = self.compile(annotation, select_format=True) + sql.append(ann_sql) + params.extend(ann_params) self.col_count = len(self.query.annotation_select) sql = ', '.join(sql) params = tuple(params) |
