From 09e1ec71dfd1e43ae422f5f9bf4525936832e0ce Mon Sep 17 00:00:00 2001 From: Sicong Date: Mon, 2 Nov 2020 22:08:42 -0800 Subject: [PATCH] Fixed #32166 -- Removed redundant definition of Greatest in test_expression_on_aggregation. --- tests/aggregation/tests.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index a759fd4d36..62704c4bd2 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -5,10 +5,10 @@ from decimal import Decimal from django.core.exceptions import FieldError from django.db import connection from django.db.models import ( - Avg, Case, Count, DecimalField, DurationField, Exists, F, FloatField, Func, + Avg, Case, Count, DecimalField, DurationField, Exists, F, FloatField, IntegerField, Max, Min, OuterRef, Subquery, Sum, Value, When, ) -from django.db.models.functions import Coalesce +from django.db.models.functions import Coalesce, Greatest from django.test import TestCase from django.test.testcases import skipUnlessDBFeature from django.test.utils import Approximate, CaptureQueriesContext @@ -1102,14 +1102,6 @@ class AggregateTestCase(TestCase): {'books_per_rating__max': 3 + 5}) def test_expression_on_aggregation(self): - - # Create a plain expression - class Greatest(Func): - function = 'GREATEST' - - def as_sqlite(self, compiler, connection, **extra_context): - return super().as_sql(compiler, connection, function='MAX', **extra_context) - qs = Publisher.objects.annotate( price_or_median=Greatest(Avg('book__rating', output_field=DecimalField()), Avg('book__price')) ).filter(price_or_median__gte=F('num_awards')).order_by('num_awards')