#14754 closed (fixed)
TypeError: '[some aggregate function]' object does not support indexing
Reported by: | master | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | relabel_aliases, aggregate | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Relabelling aliases on the query value, when this value is an Aggregate object, is expected.
A simplified example (don't look for a sense, it's just for the demo):
from django.contrib.auth.models import User emails = User.objects.values('email').annotate( cnt=Count('id'), some_int=Count('username') ).filter(some_int=F('cnt')).values_list('email', flat=True) print User.objects.filter(email__in=emails).query
produces:
File "D:\Python26\lib\site-packages\django-svn\django\db\models\sql\query.py", line 709, in change_aliases self.having.relabel_aliases(change_map) File "D:\Python26\lib\site-packages\django-svn\django\db\models\sql\where.py", line 251, in relabel_aliases child[3].relabel_aliases(change_map) File "D:\Python26\lib\site-packages\django-svn\django\db\models\sql\expressions.py", line 22, in relabel_aliases self.cols[node] = (change_map.get(col[0], col[0]), col[1]) TypeError: 'Count' object does not support indexing
A patch is provided, for django\db\models\sql\expressions.py
Attachments (1)
Change History (3)
by , 14 years ago
Attachment: | aggregates_relabel_aliases.diff added |
---|
comment:1 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 14 years ago
Note:
See TracTickets
for help on using tickets.
(In [14681]) Fixed #14754 -- corrected using an aggregate in an F expressions when that queryset is later used in a subquery. Thanks to master for the patch.