From 0f3e1a54bfa19f034f88bf3c25c67402d19e906c Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Wed, 6 Oct 2021 01:25:17 -0400 Subject: [PATCH] Refs #26430 -- Removed unused branch in sql.Query.get_count(). Now that sql.Query.get_aggregation() properly deals with empty result sets summary Count() annotations cannot result in None. Unused since 9f3cce172f6913c5ac74272fa5fc07f847b4e112. --- django/db/models/sql/query.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index b02d19071b..79499b2854 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -513,10 +513,7 @@ class Query(BaseExpression): """ obj = self.clone() obj.add_annotation(Count('*'), alias='__count', is_summary=True) - number = obj.get_aggregation(using, ['__count'])['__count'] - if number is None: - number = 0 - return number + return obj.get_aggregation(using, ['__count'])['__count'] def has_filters(self): return self.where