#34255: Annotation/group by with an expression on psycopg3 -------------------------------------+------------------------------------- Reporter: Guillaume Andreu | Owner: nobody Sabater | Type: Bug | Status: new Component: Database layer | Version: dev (models, ORM) | Severity: Release blocker | Resolution: Keywords: orm postgres | Triage Stage: Accepted psycopg3 annotation groupby | Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak): Regression test for the Django test suite: {{{ #!diff diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 54e1e6f13a..e166a2ae3c 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1614,6 +1614,27 @@ class AggregateTestCase(TestCase): ).annotate(total=Count("*")) self.assertEqual(dict(has_long_books_breakdown), {True: 2, False: 3}) + def test_group_by_nested_expression_with_params(self): + books_qs = ( + Book.objects.annotate( + greatest_rating=Greatest( + "rating", Value(4.5), output_field=DecimalField() + ) + ) + .values( + "greatest_rating", + ) + .annotate( + min_price=Max("price"), + bigger=Greatest("min_price", "greatest_rating"), + ) + .values_list("bigger", flat=True) + ) + self.assertCountEqual( + books_qs, + [Decimal("82.8"), Decimal("75")], + ) + @skipUnlessDBFeature("supports_subqueries_in_group_by") def test_aggregation_subquery_annotation_related_field(self): publisher = Publisher.objects.create(name=self.a9.name, num_awards=2) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/34255#comment:9> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/01070185ab16c116-32498c66-c1e1-4fdc-bba7-db71c4f15c5e-000000%40eu-central-1.amazonses.com.