mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #24649 -- Allowed using Avg aggregate on non-numeric field types.
This commit is contained in:
@@ -160,6 +160,9 @@ class BaseDatabaseFeatures(object):
|
||||
# Support for the DISTINCT ON clause
|
||||
can_distinct_on_fields = False
|
||||
|
||||
# Can the backend use an Avg aggregate on DurationField?
|
||||
can_avg_on_durationfield = True
|
||||
|
||||
# Does the backend decide to commit before SAVEPOINT statements
|
||||
# when autocommit is disabled? http://bugs.python.org/issue8145#msg109965
|
||||
autocommits_when_autocommit_is_off = False
|
||||
|
||||
@@ -40,6 +40,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||
uppercases_column_names = True
|
||||
# select for update with limit can be achieved on Oracle, but not with the current backend.
|
||||
supports_select_for_update_with_limit = False
|
||||
can_avg_on_durationfield = False # Pending implementation (#24699).
|
||||
|
||||
def introspected_boolean_field_type(self, field=None, created_separately=False):
|
||||
"""
|
||||
|
||||
@@ -75,12 +75,8 @@ class Avg(Aggregate):
|
||||
name = 'Avg'
|
||||
|
||||
def __init__(self, expression, **extra):
|
||||
super(Avg, self).__init__(expression, output_field=FloatField(), **extra)
|
||||
|
||||
def convert_value(self, value, expression, connection, context):
|
||||
if value is None:
|
||||
return value
|
||||
return float(value)
|
||||
output_field = extra.pop('output_field', FloatField())
|
||||
super(Avg, self).__init__(expression, output_field=output_field, **extra)
|
||||
|
||||
|
||||
class Count(Aggregate):
|
||||
|
||||
Reference in New Issue
Block a user