1
0
mirror of https://github.com/django/django.git synced 2025-10-26 15:16:09 +00:00

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
This commit is contained in:
Malcolm Tredinnick
2008-12-10 05:19:27 +00:00
parent 7030ab9a72
commit a1cbeb9afb
4 changed files with 36 additions and 0 deletions

View File

@@ -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()