Will crash with the following traceback:
{{{
Traceback (most recent call last):
File "/tests/django/tests/aggregation/test_filter_argument.py", line
146, in test_filtered_aggregate_with_exists
aggregate = Book.objects.values('publisher').aggregate(
File "/tests/django/django/db/models/query.py", line 405, in aggregate
return query.get_aggregation(self.db, kwargs)
File "/tests/django/django/db/models/sql/query.py", line 501, in
get_aggregation
result = compiler.execute_sql(SINGLE)
File "/tests/django/django/db/models/sql/compiler.py", line 1189, in
execute_sql
sql, params = self.as_sql()
File "/tests/django/django/db/models/sql/compiler.py", line 531, in
as_sql
extra_select, order_by, group_by = self.pre_sql_setup()
File "/tests/django/django/db/models/sql/compiler.py", line 59, in
pre_sql_setup
self.setup_query()
File "/tests/django/django/db/models/sql/compiler.py", line 50, in
setup_query
self.select, self.klass_info, self.annotation_col_map =
self.get_select()
File "/tests/django/django/db/models/sql/compiler.py", line 267, in
get_select
sql, params = self.compile(col)
File "/tests/django/django/db/models/sql/compiler.py", line 463, in
compile
sql, params = node.as_sql(self, self.connection)
File "/tests/django/django/db/models/aggregates.py", line 90, in as_sql
return sql, params + filter_params
TypeError: can only concatenate list (not "tuple") to list
}}}
The following patch should fix the issue:
{{{
diff --git a/django/db/models/aggregates.py
b/django/db/models/aggregates.py
index 596a161669..8c4eae7906 100644
--- a/django/db/models/aggregates.py
+++ b/django/db/models/aggregates.py
@@ -87,7 +87,7 @@ class Aggregate(Func):
compiler, connection, template=template,
filter=filter_sql,
**extra_context
)
- return sql, params + filter_params
+ return sql, (*params, *filter_params)
else:
copy = self.copy()
copy.filter = None
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33262>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* has_patch: 0 => 1
Comment:
PR: https://github.com/django/django/pull/15052
--
Ticket URL: <https://code.djangoproject.com/ticket/33262#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/33262#comment:2>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/33262#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"a934d377af2f90329485917fead8723f45d7a56e" a934d377]:
{{{
#!CommitTicketReference repository=""
revision="a934d377af2f90329485917fead8723f45d7a56e"
Fixed #33262 -- Fixed crash of conditional aggregation on Exists().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33262#comment:4>