#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 Honza Král <[EMAIL PROTECTED]>):
Replying to [comment:6 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?
either it will be the whole object, or just an id, having a lazy object
doesn't seem to have any effect here
> "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)
nice, but what field should be first in your example? name, SUM( pay ) or
AVG( pay ) ??
I am sorry, I didn't have the time to advance with this, plus the queryset
refactoring came around and that really needs to be done first.
--
Ticket URL: <http://code.djangoproject.com/ticket/3566#comment:7>
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
-~----------~----~----~----~------~----~------~--~---