#3566: Proposal: ORM aggregation support
-------------------------------------------------+--------------------------
Reporter: Honza Král <[EMAIL PROTECTED]> | Owner: adrian
Status: new | Component:
Database wrapper
Version: SVN | Resolution:
Keywords: orm aggregation group by | Stage:
Design decision needed
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------------------------------+--------------------------
Comment (by Ciantic):
"how to deal with grouping by foreign key? the best seems to include the
whole object in the result, not just the ID. (isn't it too magical?)"
Surely, aren't they lazy after all? So they will be not queried until you
access them?
"how to specify ordering?"
How about queryset.aggregate( group_by=( 'name', 'city' ), sum=( 'pay',
'some_other_field' ), avg=( 'pay', 'age' ), count=True
).order_by(group_by='name', sum='-pay', avg='pay')
(- sign represents the reversed order as it represents it in normal
querysets too)
"how to best present the results? originally I thought that fields in
group_by will be on the same level as min or max, but Tim Chase pointed
out that it could clash if the model has a field named min ."
I see no collision in current result.
--
Ticket URL: <http://code.djangoproject.com/ticket/3566#comment:6>
Django Code <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
-~----------~----~----~----~------~----~------~--~---