diff options
| author | Michal Mládek <osvc.04923031@gmail.com> | 2025-05-26 18:37:34 +0200 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-12-15 15:23:51 -0500 |
| commit | 2ce5cb0f7a4618dfdc5f5c10e53e2e9b9543d298 (patch) | |
| tree | 43bc9830c1c95fbe631f54eb7b2c33ec50c7311c /tests | |
| parent | 0174a85770356fd12e4c8daa42a4f1c752ae00e6 (diff) | |
Fixed #26434 -- Removed faulty clearing of ordering field when missing from explicit grouping.
Co-authored-by: Simon Charette <charette.s@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/aggregation_regress/tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 3e1a6a71f9..c7d9271dd8 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -171,6 +171,24 @@ 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.order_by("id").count(), len(qs.order_by("id"))) + self.assertEqual(qs.extra(order_by=["id"]).count(), len(qs.order_by("id"))) + def test_annotation_with_value(self): values = ( Book.objects.filter( |
