diff options
| -rw-r--r-- | django/db/models/sql/query.py | 8 | ||||
| -rw-r--r-- | tests/aggregation_regress/tests.py | 19 |
2 files changed, 1 insertions, 26 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 8f9349e7eb..84950d4ec0 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -2346,13 +2346,7 @@ class Query(BaseExpression): query (not even the model's default). """ if not force and ( - self.is_sliced - or self.distinct_fields - or self.select_for_update - or ( - isinstance(self.group_by, tuple) - and not {*self.order_by, *self.extra_order_by}.issubset(self.group_by) - ) + self.is_sliced or self.distinct_fields or self.select_for_update ): return self.order_by = () diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 5f17169dc6..3e1a6a71f9 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -171,25 +171,6 @@ class AggregationTests(TestCase): for attr, value in kwargs.items(): self.assertEqual(getattr(obj, attr), value) - def test_count_preserve_group_by(self): - # new release of the same book - Book.objects.create( - isbn="113235613", - name=self.b4.name, - pages=self.b4.pages, - rating=4.0, - price=Decimal("39.69"), - contact=self.a5, - publisher=self.p3, - pubdate=datetime.date(2018, 11, 3), - ) - qs = Book.objects.values("contact__name", "publisher__name").annotate( - publications=Count("id") - ) - self.assertEqual(qs.count(), Book.objects.count() - 1) - self.assertEqual(qs.order_by("id").count(), Book.objects.count()) - self.assertEqual(qs.extra(order_by=["id"]).count(), Book.objects.count()) - def test_annotation_with_value(self): values = ( Book.objects.filter( |
