[Django] #28277: Validate that annotate() and aggregate() args and kwarg values are expressions

8 views
Skip to first unread message

Django

unread,
Jun 6, 2017, 12:51:33 PM6/6/17
to django-...@googlegroups.com
#28277: Validate that annotate() and aggregate() args and kwarg values are
expressions
-------------------------------------+-------------------------------------
Reporter: Tim | Owner: nobody
Graham |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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'
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28277>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 27, 2017, 7:49:14 AM6/27/17
to django-...@googlegroups.com
#28277: Validate that annotate() and aggregate() args and kwarg values are
expressions
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: felixxm
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => assigned
* owner: nobody => felixxm


--
Ticket URL: <https://code.djangoproject.com/ticket/28277#comment:1>

Django

unread,
Jun 27, 2017, 8:22:36 AM6/27/17
to django-...@googlegroups.com
#28277: Validate that annotate() and aggregate() args and kwarg values are
expressions
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: felixxm
Type: | Status: assigned
Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/8680 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/28277#comment:2>

Django

unread,
Jun 29, 2017, 12:25:54 PM6/29/17
to django-...@googlegroups.com
#28277: Validate that annotate() and aggregate() args and kwarg values are
expressions
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: felixxm
Type: | Status: closed

Cleanup/optimization |
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"6e228d0b659c9779da7d392a75c7d2fbb42fb3cb" 6e228d0b]:
{{{
#!CommitTicketReference repository=""
revision="6e228d0b659c9779da7d392a75c7d2fbb42fb3cb"
Fixed #28277 -- Added validation of QuerySet.annotate() and aggregate()
args.

Thanks Tim Graham and Nick Pope for reviews.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28277#comment:3>

Reply all
Reply to author
Forward
0 new messages