Opened 7 years ago
Closed 7 years ago
#28277 closed Cleanup/optimization (fixed)
Validate that annotate() and aggregate() args and kwarg values are expressions
Reported by: | Tim Graham | Owned by: | Mariusz Felisiak |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The current error messages are unhelpful. For example:
>>> Book.objects.aggregate(alias=Max('price'), output_field=FloatField()) ... File "/home/tim/code/django/django/db/models/sql/query.py", line 974, in add_annotation annotation = annotation.resolve_expression(self, allow_joins=True, reuse=None, AttributeError: 'FloatField' object has no attribute 'resolve_expression'
or
>>> Book.objects.annotate(FloatField())) File "/home/tim/code/django/django/db/models/query.py", line 890, in annotate if arg.default_alias in kwargs: AttributeError: 'FloatField' object has no attribute 'default_alias'
Change History (3)
comment:1 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 7 years ago
Has patch: | set |
---|
Note:
See TracTickets
for help on using tickets.
PR