Opened 13 years ago

Closed 12 years ago

#1435 closed enhancement (duplicate)

[patch] Add aggregate function support.

Reported by: rock@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: magic-removal
Severity: normal Keywords: aggregate sum count min max stddev avg
Cc: gary.wilson@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Attachments (2)

agg_funcs.diff (16.0 KB) - added by Jacob 13 years ago.
aggr_functions-r3897.diff (13.6 KB) - added by wiz 12 years ago.
updated patch for r3897 of trunk

Download all attachments as: .zip

Change History (12)

comment:1 Changed 13 years ago by Jacob

Description: modified (diff)
Summary: Add Aggregate Function support.[path] Add aggregate function support.

Changed 13 years ago by Jacob

Attachment: agg_funcs.diff added

comment:2 Changed 13 years ago by anonymous

Summary: [path] Add aggregate function support.[patch] Add aggregate function support.

comment:3 Changed 13 years ago by Russell Keith-Magee

(at the suggestion of Stephen Newey <stephen.newey@…>) One piece of aggregate functionality that doesn't directly map to an SQL query is 'exists' - i.e., select all objects where at least one object exists in the relation. This can be currently 'faked' using a query like:


but it would be nice if an 'exists' query clause were to be included as part of the aggregate effort. Something like:


or, more generally:


selecting all topics with more than 5 articles.

comment:4 Changed 13 years ago by Russell Keith-Magee

Examples again, this time with wikiformatting:




comment:5 Changed 13 years ago by Gary Wilson <gary.wilson@…>

milestone: Version 0.92Version 1.0

0.92 is long gone.

Changed 12 years ago by wiz

Attachment: aggr_functions-r3897.diff added

updated patch for r3897 of trunk

comment:6 Changed 12 years ago by Gary Wilson <gary.wilson@…>

Cc: gary.wilson@… added

comment:7 Changed 12 years ago by (none)

milestone: Version 1.0

Milestone Version 1.0 deleted

comment:8 Changed 12 years ago by Simon G. <dev@…>

Needs documentation: set
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

I think this is close to being ready, but needs documentation and testing.

comment:9 Changed 12 years ago by Russell Keith-Magee

Triage Stage: AcceptedDesign decision needed

This topic comes up from time to time in the django-users and django-dev mailing lists; while aggregate functions are something that we should be striving to add to Django, I am not happy with the patch suggested in this proposal.

The archives contain many discussions in which I have talked about my reservations on this patch;
This thread:

has at least one proposal for a more wide ranging approach.

comment:10 Changed 12 years ago by Russell Keith-Magee

Resolution: duplicate
Status: newclosed

I'm closing this ticket in favour of #3566, which is a duplicate that seems to have a larger discussion around it.

Note: See TracTickets for help on using tickets.
Back to Top