diff --git a/django/contrib/gis/db/models/sql/query.py b/django/contrib/gis/db/models/sql/query.py
index 52f521d..d38045e 100644
a
|
b
|
class GeoQuery(sql.Query):
|
78 | 78 | col_aliases.add(col[1]) |
79 | 79 | else: |
80 | 80 | result.append(col.as_sql(quote_func=qn)) |
| 81 | |
81 | 82 | if hasattr(col, 'alias'): |
82 | 83 | aliases.add(col.alias) |
83 | 84 | col_aliases.add(col.alias) |
| 85 | |
84 | 86 | elif self.default_cols: |
85 | 87 | cols, new_aliases = self.get_default_columns(with_aliases, |
86 | 88 | col_aliases) |
87 | 89 | result.extend(cols) |
88 | 90 | aliases.update(new_aliases) |
| 91 | |
| 92 | result.extend([ |
| 93 | '%s%s' % ( |
| 94 | aggregate.as_sql(quote_func=qn), |
| 95 | alias is not None and ' AS %s' % alias or '' |
| 96 | ) |
| 97 | for alias, aggregate in self.aggregate_select.items() |
| 98 | ]) |
| 99 | |
89 | 100 | # This loop customized for GeoQuery. |
90 | 101 | if not self.aggregate: |
91 | 102 | for (table, col), field in izip(self.related_select_cols, self.related_select_fields): |