summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-12-10 05:19:27 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-12-10 05:19:27 +0000
commita1cbeb9afbbf0f16e1ffa1891575fbc2c3edae74 (patch)
treec5741e275b870b9d5decd0f5ab716497b9305a2c /django/db/models/sql/query.py
parent7030ab9a72ea590b359c22644e45edaf05dd8b5c (diff)
If an SQL query doesn't specify any ordering, avoid the implicit sort
that happens with MySQL when a "GROUP BY" clause is included. This is a backend-specific operation, so any other databases requiring similar encouragement can have a function added to their own backend code. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9637 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index e30deee29b..8c5ef3355e 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -288,6 +288,8 @@ class BaseQuery(object):
if self.group_by:
grouping = self.get_grouping()
result.append('GROUP BY %s' % ', '.join(grouping))
+ if not ordering:
+ ordering = self.connection.ops.force_no_ordering()
if self.having:
having, h_params = self.get_having()