Re: Aggregate class: a first-attempt

2007-02-24 Thread Honza Král
I created a ticket for this: http://code.djangoproject.com/ticket/3566 any comments are welcome On 2/23/07, Tim Chase <[EMAIL PROTECTED]> wrote: > > >> items.aggregate((,), sum=( > >> 'field1', > >> 'field2', > >> ... > >> 'field20', > >> 'field21', > >> )

Re: Aggregate class: a first-attempt

2007-02-23 Thread Tim Chase
>> items.aggregate((,), sum=( >> 'field1', >> 'field2', >> ... >> 'field20', >> 'field21', >> ), average=( >> 'field1', >> 'field2', >> ... >> 'field20', >> 'field21', >> )) > > well, in this extreme example, I would

Re: Aggregate class: a first-attempt

2007-02-23 Thread Honza Král
On 2/23/07, Tim Chase <[EMAIL PROTECTED]> wrote: > > >> quseryset = Model.objects.all() > >> queryset.aggregate( ( 'name', 'city' ), sum=( 'pay', > >>> 'some_other_field' ), avg=( 'pay', 'age' ), count=True ) > >> I like this calling interface as an alternate method for its > >> fine-tuned

Re: Aggregate class: a first-attempt

2007-02-23 Thread Tim Chase
>> quseryset = Model.objects.all() >> queryset.aggregate( ( 'name', 'city' ), sum=( 'pay', >>> 'some_other_field' ), avg=( 'pay', 'age' ), count=True ) >> I like this calling interface as an alternate method for its >> fine-tuned control, but there are times it would be nice to not >> have

Re: Aggregate class: a first-attempt

2007-02-22 Thread Honza Král
On 2/23/07, Tim Chase <[EMAIL PROTECTED]> wrote: > > >> I haven't yet figured out a way to suppress the order_by portion, > >> so what's currently in there is an ugly hack. But it would need > >> to prevent the standard methods from inserting an ORDER BY clause > >> against a non-aggregated field.

Re: Aggregate class: a first-attempt

2007-02-22 Thread Tim Chase
>> I haven't yet figured out a way to suppress the order_by portion, >> so what's currently in there is an ugly hack. But it would need >> to prevent the standard methods from inserting an ORDER BY clause >> against a non-aggregated field. > > if you add an empty call (no parameters) to order_by

Re: Aggregate class: a first-attempt

2007-02-22 Thread Honza Král
On 2/22/07, Tim Chase <[EMAIL PROTECTED]> wrote: > > Below I've pasted my first attempt at an aggregate function > class. Its __init__ takes a queryset (and an optional list of > aggregate functions to perform if, say, you only want the "sum"s > rather than min/max/avg/sum). Thus you should be ab

Aggregate class: a first-attempt

2007-02-22 Thread Tim Chase
Below I've pasted my first attempt at an aggregate function class. Its __init__ takes a queryset (and an optional list of aggregate functions to perform if, say, you only want the "sum"s rather than min/max/avg/sum). Thus you should be able to do things like >>>class Foo(Model): ... blah