Opened 18 years ago

Closed 17 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

Description (last modified by Jacob)

Attachments (2)

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

Download all attachments as: .zip

Change History (12)

comment:1 by Jacob, 18 years ago

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

by Jacob, 18 years ago

Attachment: agg_funcs.diff added

comment:2 by anonymous, 18 years ago

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

comment:3 by Russell Keith-Magee, 18 years ago

(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:

Topic.objects.filter(articleidisnull=False).distinct()

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

Topic.objects.filter(articleexists=True)

or, more generally:

Topic.objects.filter(articlecount_gt=5)

selecting all topics with more than 5 articles.

comment:4 by Russell Keith-Magee, 18 years ago

Examples again, this time with wikiformatting:

Topic.objects.filter(article__id__isnull=False).distinct()

Topic.objects.filter(article__exists=True)

Topic.objects.filter(article__count_gt=5)

comment:5 by Gary Wilson <gary.wilson@…>, 18 years ago

milestone: Version 0.92Version 1.0

0.92 is long gone.

by wiz, 18 years ago

Attachment: aggr_functions-r3897.diff added

updated patch for r3897 of trunk

comment:6 by Gary Wilson <gary.wilson@…>, 18 years ago

Cc: gary.wilson@… added

comment:7 by (none), 17 years ago

milestone: Version 1.0

Milestone Version 1.0 deleted

comment:8 by Simon G. <dev@…>, 17 years ago

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 by Russell Keith-Magee, 17 years ago

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: http://groups.google.com/group/django-developers/browse_thread/thread/e53a62e1c73871b8/092e6168703e27c3

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

comment:10 by Russell Keith-Magee, 17 years ago

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