diff options
| author | Simon Charette <charette.s@gmail.com> | 2013-08-19 20:39:30 -0400 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2013-08-21 22:30:02 +0100 |
| commit | 77478d84ade2e7b4720231e52d0c517741b18768 (patch) | |
| tree | c61871a1709d1b17f6fa96480ffcd413d388a5b7 | |
| parent | eadecf0cdbc30d2351b91ae77d7a441f592bc5d0 (diff) | |
Fixed an aggregation test failure on MySQL.
| -rw-r--r-- | tests/aggregation/tests.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 7d2490a77c..ce7f4e9b9d 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals import datetime from decimal import Decimal +import re from django.db import connection from django.db.models import Avg, Sum, Count, Max, Min @@ -640,5 +641,14 @@ class BaseAggregateTestCase(TestCase): self.assertEqual(len(captured_queries), 1) qstr = captured_queries[0]['sql'].lower() self.assertNotIn('for update', qstr) - self.assertNotIn('order by', qstr) + forced_ordering = connection.ops.force_no_ordering() + if forced_ordering: + # If the backend needs to force an ordering we make sure it's + # the only "ORDER BY" clause present in the query. + self.assertEqual( + re.findall(r'order by (\w+)', qstr), + [', '.join(forced_ordering).lower()] + ) + else: + self.assertNotIn('order by', qstr) self.assertEqual(qstr.count(' join '), 0) |
