mirror of
https://github.com/django/django.git
synced 2025-12-04 00:55:36 +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:
parent
c58a8acd41
commit
04518e310d
7 changed files with 78 additions and 13 deletions
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue