summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-09-16 14:24:59 +0500
committerSergey Fedoseev <fedoseev.sergey@gmail.com>2017-09-16 14:31:51 +0500
commit873858009c931d6e7bf979800cc0d16b5a71f24e (patch)
treececb685d13c2c4665693c1e38ae5d2571c4bfe80
parent86a18dc46aae3a4a6410e3f3d864fa0ec4e5b2cd (diff)
Simplified Count.convert_value() and RegrCount.convert_value().
-rw-r--r--django/contrib/postgres/aggregates/statistics.py4
-rw-r--r--django/db/models/aggregates.py4
2 files changed, 2 insertions, 6 deletions
diff --git a/django/contrib/postgres/aggregates/statistics.py b/django/contrib/postgres/aggregates/statistics.py
index 5f5ddc4757..db6c8e6dc5 100644
--- a/django/contrib/postgres/aggregates/statistics.py
+++ b/django/contrib/postgres/aggregates/statistics.py
@@ -42,9 +42,7 @@ class RegrCount(StatAggregate):
output_field = IntegerField()
def convert_value(self, value, expression, connection):
- if value is None:
- return 0
- return int(value)
+ return 0 if value is None else value
class RegrIntercept(StatAggregate):
diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py
index b70ea03838..365a885b53 100644
--- a/django/db/models/aggregates.py
+++ b/django/db/models/aggregates.py
@@ -125,9 +125,7 @@ class Count(Aggregate):
return dict(options, distinct=self.extra['distinct'] != '')
def convert_value(self, value, expression, connection):
- if value is None:
- return 0
- return int(value)
+ return 0 if value is None else value
class Max(Aggregate):