Re: On aggregates

2008-05-28 Thread Nicolas Lara
> > Providing a way to count different fields is a good idea, and the > approach you've described looks good to me. I just wanted to make sure > that the simplest case (count all instances) is trivial (i.e., doesn't > require explicit naming of the PK field). > This is fixed in the latest revisio

Re: On aggregates

2008-05-24 Thread Karen Tracey
On Fri, May 9, 2008 at 12:46 AM, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > As a hint to the community - one of the best suggestions we can have > at this stage of the project is a set of interesting problems to > solve. This would give us a set of concrete 'problems' that we can use > to ev

Re: On aggregates

2008-05-24 Thread [EMAIL PROTECTED]
All of this looks pretty good. The 2 things I have to say are, a) I think the F() way of dealing with that, in place of list comprehension is the right way to go, there has been a lot of good work on that patch, and I think it works well, conceptually, with this. b) Is there any plan to make sele

Re: On aggregates

2008-05-24 Thread Nicolas E. Lara G.
Hi Russell, I have been adding your test cases to the test suit and ran into troubles with some of them so I would like to know a bit more on what you were expecting from the queries: > * Does Author X have any friends? > (aggregate on a related object) > Author.objects.filter(pk=1).aggregate(Co

RE: On aggregates

2008-05-13 Thread David Cramer
jango-developers@googlegroups.com Subject: Re: On aggregates Hi, > DISTINCT and GROUP BY are both annotating the results. Taking many > rows, and turning them into a single row based on a key. DISTINCT would > be the same as GROUP BY every, field, in, the, select. Mathematically true, but I

Re: On aggregates

2008-05-13 Thread Sander Steffann
Hi, > DISTINCT and GROUP BY are both annotating the results. Taking many > rows, and turning them into a single row based on a key. DISTINCT would > be the same as GROUP BY every, field, in, the, select. Mathematically true, but I think having two separate concepts makes the code easier to read

Re: On aggregates

2008-05-13 Thread Collin Grady
David Cramer said the following: > DISTINCT and GROUP BY are both annotating the results. Taking many rows, > and turning them into a single row based on a key. DISTINCT would be the > same as GROUP BY every, field, in, the, select. But forcing people to group by every field they select in orde

Re: On aggregates

2008-05-13 Thread Nicolas Lara
Hi, David, even if annotate() actually _could_ replace distinct()... Wouldn't you like to keep the syntactic sugar around? not to mention the backward compatibility... Also, for users looking for the simple distinct behaviour, it is very complex and unnecessary having to think of it in terms of gr

Re: On aggregates

2008-05-13 Thread David Cramer
DISTINCT and GROUP BY are both annotating the results. Taking many rows, and turning them into a single row based on a key. DISTINCT would be the same as GROUP BY every, field, in, the, select. On Tue, May 13, 2008 at 10:29 AM, Collin Grady <[EMAIL PROTECTED]> wrote: > > David Cramer said the fol

Re: On aggregates

2008-05-13 Thread Collin Grady
David Cramer said the following: > If that is the case, then annotate would replace GROUP BY, and should > also be able to replace distinct(). Why would replacing distinct() ever make any sense? -- Collin Grady --~--~-~--~~~---~--~~ You received this message bec

Re: On aggregates

2008-05-13 Thread David Cramer
That's much more clear than what I had been reading. If that is the case, then annotate would replace GROUP BY, and should also be able to replace distinct(). On May 12, 9:27 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On Tue, May 13, 2008 at 12:01 PM, David Cramer <[EMAIL PROTECTED]>

Re: On aggregates

2008-05-13 Thread Nicolas Lara
Thanks for the sugestion Alex, I will do that. Also, Im glad to see you are following the updates closely :) On Mon, May 12, 2008 at 10:26 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hey, just saw the update, and my suggestions would be, instead of > using round() figure out how many

Re: On aggregates

2008-05-12 Thread Russell Keith-Magee
On Tue, May 13, 2008 at 12:01 PM, David Cramer <[EMAIL PROTECTED]> wrote: > > I realize how the aggregates work, but if annotate is just for > aggregates, then remove it as a standalone method. If it's not, then > it should solve all the problems with one blow. Pardon? Annotate and aggregate

Re: On aggregates

2008-05-12 Thread David Cramer
I realize how the aggregates work, but if annotate is just for aggregates, then remove it as a standalone method. If it's not, then it should solve all the problems with one blow. On May 12, 4:37 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On Mon, May 12, 2008 at 10:50 PM, David Cramer

Re: On aggregates

2008-05-12 Thread [EMAIL PROTECTED]
Hey, just saw the update, and my suggestions would be, instead of using round() figure out how many places of congruency there are between the backends and use the ... syntax instead. For example if: pgsql: 37.4697 sqlite: 37.4701 mysql: 37.47 just print out 37.4... On May 12, 6:37 pm, "Russell

Re: On aggregates

2008-05-12 Thread Russell Keith-Magee
On Mon, May 12, 2008 at 10:50 PM, David Cramer <[EMAIL PROTECTED]> wrote: > > What is the difference between annotate and aggregate? They seem like > they'd do the same thing, except annotate sounds like it should be > doing GROUP BY, I don't mean to be rude, David, but the difference between

Re: On aggregates

2008-05-12 Thread David Cramer
My assumption was annotate was the equiv of GROUP BY, which is what annotate sounds like :) If that's the case, I believe annotate should also replace distinct(), as it is very very similar in its use-cases. On May 12, 12:05 pm, koenb <[EMAIL PROTECTED]> wrote: > If I understand it correctly, th

Re: On aggregates

2008-05-12 Thread koenb
If I understand it correctly, the aggregate and annotate ideas are result driven, not by the SQL that might be involved (which should indeed be entirely hidden). Aggregate normally gives one result, annotate gives you a bunch of objects, but with extra information PER object (normally from an aggr

Re: On aggregates

2008-05-12 Thread David Cramer
What is the difference between annotate and aggregate? They seem like they'd do the same thing, except annotate sounds like it should be doing GROUP BY, which, if that's the case, then this goes against the very reasoning which a group_by or something similar should not be used. The logic in the i

Re: On aggregates

2008-05-10 Thread Russell Keith-Magee
On Sat, May 10, 2008 at 2:37 PM, Nicolas Lara <[EMAIL PROTECTED]> wrote: > > Hello, > The choice of using Decimal was not mine but that of the modules that > connect to the backends (postgres in this case), and this is one of > the problems I am facing right now. Different backends return the > re

Re: On aggregates

2008-05-10 Thread Nicolas Lara
If I understand correctely you are trying to do something like: "Give me the and the sum of the financial transactions of type 'M' between a given date range for each contract ordered by id and short title)" Is that the kind of aggregate you needed? This could be expressed as: c = Contract.obj

Re: On aggregates

2008-05-09 Thread Nicolas Lara
It is not possible yet. But it will after the first stage (basic stuff) is working correctely. A great help would be, as Russell suggests, providing some complex cases of aggregates (the actual plain english problems that want to be solved with aggregates) so we can see if the proposed functionali

Re: On aggregates

2008-05-09 Thread Nicolas Lara
Hello, The choice of using Decimal was not mine but that of the modules that connect to the backends (postgres in this case), and this is one of the problems I am facing right now. Different backends return the results in different formats (Postgres: Decimal, SQLite: float... etc) I am looking int

Re: On aggregates

2008-05-09 Thread Alen Ribic
Here is one of my current real-world, common, examples: Monthly maintenance costs - Report custom_sql_query = """ SELECT c.id, p.short_title, sum(f.amount) FROM manager_contract c, manager_financialtransaction f, manager_property p WHERE f.pub_date >= '%s' and f.p

Re: On aggregates

2008-05-09 Thread Russell Keith-Magee
On Fri, May 9, 2008 at 3:58 PM, Alen Ribic <[EMAIL PROTECTED]> wrote: > > Reporting is quite common in my area of work at the moment and most of > the time some form of aggregation is required to build meaningful > reports. (For such case I have substantially more custom/native > queries then stan

Re: On aggregates

2008-05-09 Thread Alen Ribic
Reporting is quite common in my area of work at the moment and most of the time some form of aggregation is required to build meaningful reports. (For such case I have substantially more custom/native queries then standard ones.) -Alen (PS. if there is a need to give some real example with regard

Re: On aggregates

2008-05-08 Thread Russell Keith-Magee
On Fri, May 9, 2008 at 5:38 AM, Nicolas E. Lara G. <[EMAIL PROTECTED]> wrote: > > Currently there is support for both aggregate and annotate on the > simplest level. Some tests might be found under tests/modeltests/ > aggregation/ of the current state of the project. They can probably do > as docu

Re: On aggregates

2008-05-08 Thread [EMAIL PROTECTED]
And a second question, does filtering on an annotated field work, for example: Tag.objects.all().annotate(num_articles=Count('articles')).filter(num_articles__gt=2) which return all tags who have more than 2 articles. On May 8, 4:51 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I haven't h

Re: On aggregates

2008-05-08 Thread [EMAIL PROTECTED]
I haven't had a ton of time to look over everything(just read the tests so far), but why did you choose to return things as decimals in place of a float? On May 8, 4:38 pm, "Nicolas E. Lara G." <[EMAIL PROTECTED]> wrote: > For those that are interested the aggregation project is hosted > inhttp: