mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #33308 -- Enabled explicit GROUP BY and ORDER BY aliases.
This ensures explicit grouping from using values() before annotating an aggregate function groups by selected aliases if supported. The GROUP BY feature is disabled on Oracle because it doesn't support it.
This commit is contained in:
committed by
Mariusz Felisiak
parent
c58a8acd41
commit
04518e310d
@@ -178,10 +178,19 @@ class AggregationTests(TestCase):
|
||||
)
|
||||
.annotate(sum_discount=Sum("discount_price"))
|
||||
)
|
||||
self.assertSequenceEqual(
|
||||
values,
|
||||
[{"discount_price": Decimal("59.38"), "sum_discount": Decimal("59.38")}],
|
||||
)
|
||||
with self.assertNumQueries(1) as ctx:
|
||||
self.assertSequenceEqual(
|
||||
values,
|
||||
[
|
||||
{
|
||||
"discount_price": Decimal("59.38"),
|
||||
"sum_discount": Decimal("59.38"),
|
||||
}
|
||||
],
|
||||
)
|
||||
if connection.features.allows_group_by_refs:
|
||||
alias = connection.ops.quote_name("discount_price")
|
||||
self.assertIn(f"GROUP BY {alias}", ctx[0]["sql"])
|
||||
|
||||
def test_aggregates_in_where_clause(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user