|
33 | 33 |
|
34 | 34 |
|
35 | 35 | class SQLCompiler(compiler.SQLCompiler): |
36 | | - |
| 36 | + |
37 | 37 | def resolve_columns(self, row, fields=()): |
38 | 38 | index_start = len(self.query.extra_select.keys()) |
39 | 39 | values = [self.query.convert_values(v, None, connection=self.connection) for v in row[:index_start]] |
@@ -115,7 +115,7 @@ def _as_sql(self, strategy): |
115 | 115 | if not ordering: |
116 | 116 | meta = self.query.get_meta() |
117 | 117 | qn = self.quote_name_unless_alias |
118 | | - # Special case: pk not in out_cols, use random ordering. |
| 118 | + # Special case: pk not in out_cols, use random ordering. |
119 | 119 | # |
120 | 120 | if '%s.%s' % (qn(meta.db_table), qn(meta.pk.db_column or meta.pk.column)) not in self.get_columns(): |
121 | 121 | ordering = ['RAND()'] |
@@ -165,7 +165,7 @@ def _as_sql(self, strategy): |
165 | 165 | result.append('WHERE %s' % where) |
166 | 166 | params.extend(w_params) |
167 | 167 |
|
168 | | - grouping, gb_params = self.get_grouping() |
| 168 | + grouping, gb_params = self.get_grouping(ordering_group_by) |
169 | 169 | if grouping: |
170 | 170 | if ordering: |
171 | 171 | # If the backend can't group by PK (i.e., any database |
@@ -241,7 +241,7 @@ def as_sql(self, with_limits=True, with_col_aliases=False): |
241 | 241 | # SQL Server 2005 |
242 | 242 | if self.connection.ops.sql_server_ver >= 2005: |
243 | 243 | sql, params = self._as_sql(USE_ROW_NUMBER) |
244 | | - |
| 244 | + |
245 | 245 | # Construct the final SQL clause, using the initial select SQL |
246 | 246 | # obtained above. |
247 | 247 | result = ['SELECT * FROM (%s) AS X' % sql] |
@@ -288,7 +288,7 @@ def as_sql(self): |
288 | 288 | result.append('VALUES (%s)' % ', '.join(values)) |
289 | 289 | params = self.query.params |
290 | 290 | sql = ' '.join(result) |
291 | | - |
| 291 | + |
292 | 292 | meta = self.query.get_meta() |
293 | 293 | if meta.has_auto_field: |
294 | 294 | # db_column is None if not explicitly specified by model field |
|
0 commit comments