#12886: .aggregate() does not honour sliced queryset
--------------------------------------+-------------------------------------
Reporter: [email protected] | Owner:
Status: new | Milestone:
Component: ORM aggregation | Version: 1.2-beta
Resolution: | Keywords:
Stage: Accepted | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------+-------------------------------------
Changes (by 3point2):
* cc: 3point2 (added)
Comment:
I've also just discovered this issue (using the Sum aggregate) and did
some poking around: get_aggregate in
source:django/trunk/django/db/models/sql/query.py calls
query.clear_limits(). With this line commented out, a query like this is
issued:
{{{
SELECT SUM("accounts_invoice"."grand_total") AS "grand_total__sum" FROM
"accounts_invoice" LIMIT 5
}}}
which seems correct. unfortunately the DB (in my case sqlite) ignores the
limit for the sum aggregate anyway.
For this to work right, the sql issued will have to look something like
{{{
SELECT SUM("grand_total") AS "grand_total__sum" FROM (SELECT * FROM
"accounts_invoice" LIMIT 5)
}}}
in other words, grab the SQL from the query as if it wasn't an aggregate,
and then nest it inside the aggregation function.
--
Ticket URL: <http://code.djangoproject.com/ticket/12886#comment:3>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.