From 42b567ab4c5bfb1bbd3e629b1079271c5ae44ea0 Mon Sep 17 00:00:00 2001 From: Chris Muthig Date: Wed, 3 Apr 2024 16:06:39 -0600 Subject: Refs #35339 -- Updated Aggregate class to return consistent source expressions. Refactored the filter and order_by expressions in the Aggregate class to return a list of Expression (or None) values, ensuring that the list item is always available and represents the filter expression. For the PostgreSQL OrderableAggMixin, the returned list will always include the filter and the order_by value as the last two elements. Lastly, emtpy Q objects passed directly into aggregate objects using Aggregate.filter in admin facets are filtered out when resolving the expression to avoid errors in get_refs(). Thanks Simon Charette for the review. --- tests/aggregation/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 4408535228..075e707102 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1291,7 +1291,7 @@ class AggregateTestCase(TestCase): def as_sql(self, compiler, connection): copy = self.copy() - copy.set_source_expressions(copy.get_source_expressions()[0:1]) + copy.set_source_expressions(copy.get_source_expressions()[0:1] + [None]) return super(MyMax, copy).as_sql(compiler, connection) with self.assertRaisesMessage(TypeError, "Complex aggregates require an alias"): -- cgit v1.3