Re: [Django] #15624: aggregate produces incorrect sql statement

9 views
Skip to first unread message

Django

unread,
Oct 10, 2011, 11:41:02 AM10/10/11
to django-...@googlegroups.com
#15624: aggregate produces incorrect sql statement
-------------------------------------+-------------------------------------
Reporter: zeroos <232002@…> | Owner:
Type: Bug | marekw2143
Component: ORM aggregation | Status: assigned
Severity: Normal | Version: SVN
Keywords: aggregate sql | Resolution:
syntax error | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by ramiro):

* has_patch: 0 => 1
* ui_ux: => 0
* needs_tests: 0 => 1
* easy: => 0


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

Django

unread,
Nov 3, 2011, 3:02:49 PM11/3/11
to django-...@googlegroups.com
#15624: aggregate produces incorrect sql statement
-------------------------------------+-------------------------------------
Reporter: zeroos <232002@…> | Owner:
Type: Bug | Status: new
Component: ORM aggregation | Version: SVN
Severity: Normal | Resolution:
Keywords: aggregate sql | Triage Stage: Accepted
syntax error | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 1 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by marekw2143):

* owner: marekw2143 =>
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/15624#comment:7>

Django

unread,
Jan 16, 2013, 11:19:54 PM1/16/13
to django-...@googlegroups.com
#15624: aggregate produces incorrect sql statement
-------------------------------------+-------------------------------------
Reporter: zeroos <232002@…> | Owner:
Type: Bug | Status: new
Component: ORM aggregation | Version: master

Severity: Normal | Resolution:
Keywords: aggregate sql | Triage Stage: Accepted
syntax error | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 1 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by stefano@…):

Hello! Any news on that? I see there's a patch, now oldish, but nothing
happened since and nobody from core has commented on it... is that patch a
viable solution?

--
Ticket URL: <https://code.djangoproject.com/ticket/15624#comment:8>

Django

unread,
Feb 19, 2013, 5:46:01 PM2/19/13
to django-...@googlegroups.com
#15624: aggregate produces incorrect sql statement
-------------------------------------+-------------------------------------
Reporter: zeroos <232002@…> | Owner: fhahn
Type: Bug | Status: assigned

Component: ORM aggregation | Version: master
Severity: Normal | Resolution:
Keywords: aggregate sql | Triage Stage: Accepted
syntax error | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by fhahn):

* cc: flo@… (added)
* owner: => fhahn
* status: new => assigned
* needs_tests: 1 => 0


Comment:

I think the problem with {{{
Book.objects.annotate(c=Count('authors')).values('c').aggregate(Max('c'))
}}} was that the call to {{{ .values('c') }}} set the {{{
aggregates_select_mask }}} to {{{ set(['c']) }}} and then {{{ c__max }}}
does not show up in {{{ aggregate_select }}}.

I've updated the patch and created a pull request:
https://github.com/django/django/pull/738

--
Ticket URL: <https://code.djangoproject.com/ticket/15624#comment:9>

Django

unread,
May 20, 2013, 11:14:42 AM5/20/13
to django-...@googlegroups.com
#15624: aggregate produces incorrect sql statement
-------------------------------------+-------------------------------------
Reporter: zeroos <232002@…> | Owner: fhahn
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: aggregate sql | Needs documentation: 0
syntax error | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by jmilner):

* cc: jmilner (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/15624#comment:11>

Django

unread,
Jul 12, 2013, 9:41:28 AM7/12/13
to django-...@googlegroups.com
#15624: annotate + aggregate produces incorrect sql statement

-------------------------------------+-------------------------------------
Reporter: zeroos <232002@…> | Owner: fhahn
Type: Bug | Status: assigned
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Ready for
Keywords: aggregate sql | checkin

syntax error | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* stage: Accepted => Ready for checkin


Comment:

Patch applies cleanly and tests pass. Would like someone more familiar
with the code to +1 before committing.

--
Ticket URL: <https://code.djangoproject.com/ticket/15624#comment:12>

Django

unread,
Jul 31, 2013, 9:17:36 AM7/31/13
to django-...@googlegroups.com
#15624: annotate + aggregate produces incorrect sql statement
-------------------------------------+-------------------------------------
Reporter: zeroos <232002@…> | Owner: fhahn
Type: Bug | Status: closed

Component: Database layer | Version: master
(models, ORM) | Resolution: fixed

Severity: Normal | Triage Stage: Ready for
Keywords: aggregate sql | checkin
syntax error | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Anssi Kääriäinen <akaariai@…>):

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


Comment:

In [changeset:"e888a9b30dd9d62a930b9244d1b5531bb17544b4"]:
{{{
#!CommitTicketReference repository=""
revision="e888a9b30dd9d62a930b9244d1b5531bb17544b4"
Fixed #15624 -- Made sure aggregations are present in SELECT
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/15624#comment:13>

Reply all
Reply to author
Forward
0 new messages