diff options
| author | Anže Pečar <anze@pecar.me> | 2026-04-18 14:54:55 +0300 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-04-19 11:03:11 +0300 |
| commit | a284a49153f005f2a7af087025e5112ba06cbd5f (patch) | |
| tree | 1adcc51fd24f588858cf28d6532bdda241214768 /tests | |
| parent | d33364c7ba330a349e38449c98494323a4ed7c8d (diff) | |
Fixed #37047 -- Fixed crash in Query.orderby_issubset_groupby for descending and random order_by strings.
Run this example:
```python
User.objects.values("is_staff").annotate(latest=Max("date_joined")).order_by("-latest").count()
```
You should see the following exception:
```
django.core.exceptions.FieldError: Cannot resolve keyword '-latest' into field.
```
Regression in 2ce5cb0f7a4618dfdc5f5c10e53e2e9b9543d298.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/aggregation_regress/tests.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 33763d589b..f2ed13420f 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -188,6 +188,14 @@ class AggregationTests(TestCase): ) 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"))) + self.assertEqual(qs.order_by("-id").count(), len(qs.order_by("-id"))) + self.assertEqual( + qs.order_by("-publications").count(), len(qs.order_by("-publications")) + ) + self.assertEqual( + qs.order_by("-contact__name").count(), len(qs.order_by("-contact__name")) + ) + self.assertEqual(qs.order_by("?").count(), len(qs.order_by("?"))) def test_annotation_with_value(self): values = ( |
