david / semanticdjango (http://semanticdjango.org/)
fork of django-trunk
The right time for a semantic contrib, that's my pony.
Clone this repository (size: 23.1 MB): HTTPS / SSH
$ hg clone http://code.welldev.org/semanticdjango
| commit 6492: | 8b4a1e3306b8 |
| parent 6491: | 90de3f2cfd0c |
| branch: | default |
Refs #10113 -- Modified the generated SQL to remove redundant GROUP BY elements, and modified the test added in [9788] to remove a test result that depended on a potentially ambiguous database ordering.
20 months ago
Changed (Δ72 bytes):
raw changeset »
django/db/models/sql/query.py (2 lines added, 1 lines removed)
tests/regressiontests/aggregation_regress/models.py (2 lines added, 2 lines removed)
Up to file-list django/db/models/sql/query.py:
| … | … | @@ -385,7 +385,8 @@ class BaseQuery(object): |
385 |
385 |
# other than MySQL), then any fields mentioned in the |
386 |
386 |
# ordering clause needs to be in the group by clause. |
387 |
387 |
if not self.connection.features.allows_group_by_pk: |
388 |
grouping.extend( |
|
388 |
grouping.extend([col for col in ordering_group_by |
|
389 |
if col not in grouping]) |
|
389 |
390 |
else: |
390 |
391 |
ordering = self.connection.ops.force_no_ordering() |
391 |
392 |
result.append('GROUP BY %s' % ', '.join(grouping)) |
Up to file-list tests/regressiontests/aggregation_regress/models.py:
| … | … | @@ -176,8 +176,8 @@ 0 |
176 |
176 |
|
177 |
177 |
# Regression for #10113 - Fields mentioned in order_by() must be included in the GROUP BY. |
178 |
178 |
# This only becomes a problem when the order_by introduces a new join. |
179 |
>>> Book.objects.annotate(num_authors=Count('authors')).order_by('publisher__name') |
|
180 |
[<Book: The Definitive Guide to Django: Web Development Done Right>, <Book: Practical Django Projects>, <Book: Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp>, <Book: Python Web Development with Django>, <Book: Artificial Intelligence: A Modern Approach>, <Book: Sams Teach Yourself Django in 24 Hours>] |
|
179 |
>>> Book.objects.annotate(num_authors=Count('authors')).order_by('publisher__name', 'name') |
|
180 |
[<Book: Practical Django Projects>, <Book: The Definitive Guide to Django: Web Development Done Right>, <Book: Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp>, <Book: Artificial Intelligence: A Modern Approach>, <Book: Python Web Development with Django>, <Book: Sams Teach Yourself Django in 24 Hours>] |
|
181 |
181 |
|
182 |
182 |
""" |
183 |
183 |
} |
