`params = params + self.query.sub_params`
''TypeError exception: can only concatenate tuple (not "list") to tuple''
This line is in the `as_sql` method of the `SQLAggregateCompiler` class.
How to reproduce:
Issue a query on a model which is related to another model, and include
distinct, order_by (on a string field in the related model), a slice and a
call to count().
e.g.
`Post.objects.distinct().order_by('author__last_name')[:20].count()`
The presence of `distinct()` above, you could argue, is not needed,
however, the above represents a simplification of the more complex query
with which I originally saw the problem, and there the `distinct()`
followed a more complex cross-table filter.
--
Ticket URL: <https://code.djangoproject.com/ticket/29108>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: felixxm (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29108#comment:1>
Comment (by felixxm):
Can you give more details about a `Post` and `Author` models? I couldn't
reproduce this issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/29108#comment:2>
Comment (by Stephen Brooks):
Replying to [comment:2 felixxm]:
> Can you give more details about a `Post` and `Author` models? I couldn't
reproduce this issue.
They are just sample model names. The important thing is that there is a
foreign key relationship from Post to Author so that the query can do an
order_by on a char field in the related model.
When trying to reproduce it, don't leave out any of: distinct, order_by(a
char field in the related model), slice, and count.
--
Ticket URL: <https://code.djangoproject.com/ticket/29108#comment:3>
* component: Uncategorized => Database layer (models, ORM)
* stage: Unreviewed => Accepted
* type: Uncategorized => Bug
* severity: Normal => Release blocker
Comment:
I reproduced with
`Book.objects.distinct().order_by('publisher__name')[:20].count()` for
`tests/aggregation` (not the right place commit the test). Bisected to
4acae21846f6212aa992763e587c7e201828d7b0.
--
Ticket URL: <https://code.djangoproject.com/ticket/29108#comment:4>
* status: new => assigned
* owner: nobody => Simon Charette
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/9660
--
Ticket URL: <https://code.djangoproject.com/ticket/29108#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"d61fe246015aa4fdc6dcb837ffb1442fa71ae586" d61fe246]:
{{{
#!CommitTicketReference repository=""
revision="d61fe246015aa4fdc6dcb837ffb1442fa71ae586"
Fixed #29108 -- Fixed crash in aggregation of distinct+ordered+sliced
querysets.
Regression in 4acae21846f6212aa992763e587c7e201828d7b0.
Thanks Stephen Brooks for the report.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29108#comment:6>
Comment (by Tim Graham <timograham@…>):
In [changeset:"8d03356d35a91e2a8536bae4319f061ccf6c0294" 8d03356]:
{{{
#!CommitTicketReference repository=""
revision="8d03356d35a91e2a8536bae4319f061ccf6c0294"
[2.0.x] Fixed #29108 -- Fixed crash in aggregation of
distinct+ordered+sliced querysets.
Regression in 4acae21846f6212aa992763e587c7e201828d7b0.
Thanks Stephen Brooks for the report.
Backport of d61fe246015aa4fdc6dcb837ffb1442fa71ae586 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29108#comment:7>