diff options
| author | Simon Charette <charette.s@gmail.com> | 2015-03-26 16:54:43 -0400 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2015-03-29 22:03:30 -0400 |
| commit | dc27f3ee0c3eb9bb17d6cb764788eeaf73a371d7 (patch) | |
| tree | df7d477583666493bb73b857d8829158b6f27030 /tests/aggregation_regress | |
| parent | 8119876d4a533fbc2ba4d1c30eaddbcc28119488 (diff) | |
Fixed #19259 -- Added group by selected primary keys support.
Diffstat (limited to 'tests/aggregation_regress')
| -rw-r--r-- | tests/aggregation_regress/tests.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index bfd202fbc9..596f69c2dc 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -7,10 +7,11 @@ from operator import attrgetter from django.contrib.contenttypes.models import ContentType from django.core.exceptions import FieldError +from django.db import connection from django.db.models import ( F, Q, Avg, Count, Max, StdDev, Sum, Value, Variance, ) -from django.test import TestCase, skipUnlessDBFeature +from django.test import TestCase, skipUnlessAnyDBFeature, skipUnlessDBFeature from django.test.utils import Approximate from django.utils import six @@ -1011,7 +1012,7 @@ class AggregationTests(TestCase): # Check that the query executes without problems. self.assertEqual(len(qs.exclude(publisher=-1)), 6) - @skipUnlessDBFeature("allows_group_by_pk") + @skipUnlessAnyDBFeature('allows_group_by_pk', 'allows_group_by_selected_pks') def test_aggregate_duplicate_columns(self): # Regression test for #17144 @@ -1041,7 +1042,7 @@ class AggregationTests(TestCase): ] ) - @skipUnlessDBFeature("allows_group_by_pk") + @skipUnlessAnyDBFeature('allows_group_by_pk', 'allows_group_by_selected_pks') def test_aggregate_duplicate_columns_only(self): # Works with only() too. results = Author.objects.only('id', 'name').annotate(num_contacts=Count('book_contact_set')) @@ -1067,13 +1068,14 @@ class AggregationTests(TestCase): ] ) - @skipUnlessDBFeature("allows_group_by_pk") + @skipUnlessAnyDBFeature('allows_group_by_pk', 'allows_group_by_selected_pks') def test_aggregate_duplicate_columns_select_related(self): # And select_related() results = Book.objects.select_related('contact').annotate( num_authors=Count('authors')) _, _, grouping = results.query.get_compiler(using='default').pre_sql_setup() - self.assertEqual(len(grouping), 1) + # In the case of `group_by_selected_pks` we also group by contact.id because of the select_related. + self.assertEqual(len(grouping), 1 if connection.features.allows_group_by_pk else 2) self.assertIn('id', grouping[0][0]) self.assertNotIn('name', grouping[0][0]) self.assertNotIn('contact', grouping[0][0]) |
