#35643 closed Bug (fixed)
Regression in Queryset sequence of value, annotate, order, value
Description ¶
Testing the 5.1RC on our project, I noticed a failure in a queryset that worked before (Django 5.0.7)
I've added a test case:
diff --git i/tests/queries/tests.py w/tests/queries/tests.py index 7ac8a65d42..c19d877ffc 100644 --- i/tests/queries/tests.py +++ w/tests/queries/tests.py @@ -1375,6 +1375,16 @@ class Queries1Tests(TestCase): self.assertCountEqual(items_after, [self.i2, self.i3, self.i4]) self.assertCountEqual(items_before, items_after) + def test_values_count_value(self): + self.assertSequenceEqual( + Tag.objects.all() + .values("category") + .annotate(Count("category")) + .order_by("-category__count") + .values_list("category", flat=True), + [self.nc1.id, None], + ) + class Queries2Tests(TestCase): @classmethod
Change History (5)
comment:1 by , 7 months ago
Owner: | set to |
---|---|
Severity: | Normal → Release blocker |
Status: | new → assigned |
comment:2 by , 7 months ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 7 months ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Bisected to b0ad41198b3e333f57351e3fce5a1fb47f23f376. The problem here is that
Aggregation.default_alias
generates an alias that is composed ofLOOKUP_SEP
. In other words, the added logic didn't account for annotations containing a lookup separator to exists.