Re: Aggregate values in objects

Sebastien Bigaret <[email protected]> Fri, 13 Aug 2004 00:32:20 +0200
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
Kertis, Dennis wrote:
> Is there a way I can get a field populated with an aggregate value. 
> i.e., I want a manager to have a field which would contain how many 
> employees work for him by doing a select count(*).  I parsed through 
> the fetching section of the doc and didn't find a way to do this.

For COUNT(*) there is a dedicated method: EC.fetchCount(), which 
has the very same syntax as EC.fetch() and returns the number of
objects matching the qualifier.

I recommend that you define a method returning this count, rather
than have an integer field populated with such a value, or else
you should be prepared to deal with every possible situations
where this count can change if you do not want that this field's
value get out of sync.

  Other aggregates are not yet supported; I believe we formerly
discussed this here, probably with Ernesto, among others.
I do not have access to the archives here, Erny could you maybe
confirm?

-- Sébastien.



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285