diff options
| author | Simon Charette <charette.s@gmail.com> | 2022-11-05 12:49:33 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-11-07 12:21:29 +0100 |
| commit | 5f09ab8c30050bbd076a9b27fb135d030c06ab75 (patch) | |
| tree | e444003f8ad4fd5f992342ae2f5faa82ee98aea7 /tests | |
| parent | 041551d716b69ee7c81199eee86a2d10a72e15ab (diff) | |
Refs #17144 -- Removed support for grouping by primary key.
No core backend require the feature anymore as it was only added to
support a MySQL'ism that has been deprecated since then.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/aggregation_regress/tests.py | 14 | ||||
| -rw-r--r-- | tests/annotations/tests.py | 15 |
2 files changed, 5 insertions, 24 deletions
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index d3d06fe076..444a55276d 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -23,7 +23,7 @@ from django.db.models import ( Variance, When, ) -from django.test import TestCase, skipUnlessAnyDBFeature, skipUnlessDBFeature +from django.test import TestCase, skipUnlessDBFeature from django.test.utils import Approximate from .models import ( @@ -1420,7 +1420,7 @@ class AggregationTests(TestCase): # The query executes without problems. self.assertEqual(len(qs.exclude(publisher=-1)), 6) - @skipUnlessAnyDBFeature("allows_group_by_pk", "allows_group_by_selected_pks") + @skipUnlessDBFeature("allows_group_by_selected_pks") def test_aggregate_duplicate_columns(self): # Regression test for #17144 @@ -1448,7 +1448,7 @@ class AggregationTests(TestCase): ], ) - @skipUnlessAnyDBFeature("allows_group_by_pk", "allows_group_by_selected_pks") + @skipUnlessDBFeature("allows_group_by_selected_pks") def test_aggregate_duplicate_columns_only(self): # Works with only() too. results = Author.objects.only("id", "name").annotate( @@ -1474,18 +1474,14 @@ class AggregationTests(TestCase): ], ) - @skipUnlessAnyDBFeature("allows_group_by_pk", "allows_group_by_selected_pks") + @skipUnlessDBFeature("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() - # 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.assertEqual(len(grouping), 2) self.assertIn("id", grouping[0][0]) self.assertNotIn("name", grouping[0][0]) self.assertNotIn("contact", grouping[0][0]) diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py index 472669288c..52c15bba87 100644 --- a/tests/annotations/tests.py +++ b/tests/annotations/tests.py @@ -550,21 +550,6 @@ class NonAggregateAnnotationTestCase(TestCase): for publisher in publishers.filter(pk=self.p1.pk): self.assertEqual(publisher["book__rating"], publisher["total"]) - @skipUnlessDBFeature("allows_group_by_pk") - def test_rawsql_group_by_collapse(self): - raw = RawSQL("SELECT MIN(id) FROM annotations_book", []) - qs = ( - Author.objects.values("id") - .annotate( - min_book_id=raw, - count_friends=Count("friends"), - ) - .order_by() - ) - _, _, group_by = qs.query.get_compiler(using="default").pre_sql_setup() - self.assertEqual(len(group_by), 1) - self.assertNotEqual(raw, group_by[0]) - def test_defer_annotation(self): """ Deferred attributes can be referenced by an annotation, |
