Opened 2 years ago
Last modified 2 years ago
#34016 closed Bug
QuerySet.values_list crash when using ArrayAgg — at Initial Version
Reported by: | Alex Kerkum | Owned by: | |
---|---|---|---|
Component: | contrib.postgres | Version: | 4.1 |
Severity: | Release blocker | Keywords: | |
Cc: | Simon Charette | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Using ArrayAgg
in combination with values_list
results in 'TypeError: Complex expressions require an alias'.
For example:
from django.contrib.postgres.aggregates import ArrayAgg SampleUser.objects.values_list(ArrayAgg("post_id")) File django/db/models/aggregates.py:98, in Aggregate.default_alias(self) 96 if len(expressions) == 1 and hasattr(expressions[0], "name"): 97 return "%s__%s" % (expressions[0].name, self.name.lower()) ---> 98 raise TypeError("Complex expressions require an alias") TypeError: Complex expressions require an alias
The expressions
variable here seems to contain [F(post_id), OrderByList()]
causing the len[expressions]
check to fail. That's as far as I got.
This still worked in 4.0.7.
Note:
See TracTickets
for help on using tickets.