diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2018-12-19 23:04:25 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2019-01-14 14:39:46 -0500 |
| commit | 6d4efa8e6a4cc7be4ba957dec71f6f63cd58700d (patch) | |
| tree | 79cffc18bd5d4d81a420145177dea5732fbc8ec7 /django | |
| parent | e85afa5943695457c85e9bc1c5dc0d985004e303 (diff) | |
Refs #28643 -- Changed Variance() to use NumericOutputFieldMixin.
Keeps precision instead of forcing DecimalField to FloatField.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/aggregates.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py index 9e4a71ef68..1b0f9d98af 100644 --- a/django/db/models/aggregates.py +++ b/django/db/models/aggregates.py @@ -3,7 +3,7 @@ Classes to represent the definitions of aggregate functions. """ from django.core.exceptions import FieldError from django.db.models.expressions import Case, Func, Star, When -from django.db.models.fields import FloatField, IntegerField +from django.db.models.fields import IntegerField from django.db.models.functions.mixins import NumericOutputFieldMixin __all__ = [ @@ -172,9 +172,8 @@ class Sum(Aggregate): return super().as_sql(compiler, connection, **extra_context) -class Variance(Aggregate): +class Variance(NumericOutputFieldMixin, Aggregate): name = 'Variance' - output_field = FloatField() def __init__(self, expression, sample=False, **extra): self.function = 'VAR_SAMP' if sample else 'VAR_POP' |
