mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Refs #27849 -- Fixed filtered aggregates crash on filters that match everything.
This commit is contained in:
committed by
Mariusz Felisiak
parent
77cf70ea96
commit
967f8750ab
@@ -105,17 +105,18 @@ class Aggregate(Func):
|
||||
if self.filter:
|
||||
if connection.features.supports_aggregate_filter_clause:
|
||||
filter_sql, filter_params = self.filter.as_sql(compiler, connection)
|
||||
template = self.filter_template % extra_context.get(
|
||||
"template", self.template
|
||||
)
|
||||
sql, params = super().as_sql(
|
||||
compiler,
|
||||
connection,
|
||||
template=template,
|
||||
filter=filter_sql,
|
||||
**extra_context,
|
||||
)
|
||||
return sql, (*params, *filter_params)
|
||||
if filter_sql:
|
||||
template = self.filter_template % extra_context.get(
|
||||
"template", self.template
|
||||
)
|
||||
sql, params = super().as_sql(
|
||||
compiler,
|
||||
connection,
|
||||
template=template,
|
||||
filter=filter_sql,
|
||||
**extra_context,
|
||||
)
|
||||
return sql, (*params, *filter_params)
|
||||
else:
|
||||
copy = self.copy()
|
||||
copy.filter = None
|
||||
|
||||
Reference in New Issue
Block a user