If annotate is equivilent to group by thenn ordering or seperation shouldn't matter. In my opinion it should function just like any other filtering and just merge together. Keep in mind I haven't read about the change to filter with qs-rf yet.
-----Original Message----- From: Nicolas Lara <[EMAIL PROTECTED]> Sent: Friday, May 02, 2008 10:12 AM To: [email protected] Subject: Re: Aggregate Support to the ORM I am not sure I agree with you on this. Since the succesive calls to aggregate/annotate would actually be constructing the elements for the final query in non ordered datastructures I think the order in which different elements are inserted to the aggregation should not matter. The values modifier on the other hand might not be commutative with the annotation. qs.values().annotate() != qs.annotate().values() where the first one would group by the elements in values while the second would use the default grouping and just have values behave as it normally does. In other words, the annotate modifier, when applied to a ValuesQuerySet manages the grouping; but a values modifier, when applied to a queryset that contains annotation, behaves normally. Having annotate not be commutative seems confusing. I can see your point on th difference between annotate(A1, A2) and annotate(A1).annotate(A2) but what is the diference between qs.annotate(A1).annotate(A2) and qs.annotate(A2).annotate(A1)?? I think the 2 options now to tackle this problem are: (1) annotate(A1, A2) would behave as SQL (when A1 is on the local model and A2 is on a join) and annotate(A1).annotate(A2) would result in doing the 2 queries and returning something as the second example of my previous post (2) Simply restrict this case. If somebody needs such a case they can just do 2 querysets or fall back to sql. I am more inclined towards (2) since (1) seems hard to grasp for the users, error prone and would add innecesary complexity to the orm's code that would need to be maintained in the future. Also the use case is unusual enough so it can fall in the 20% roll your own sql side. On Thu, May 1, 2008 at 4:53 PM, Yuri Baburov <[EMAIL PROTECTED]> wrote: > > can this be considered as difference of complex apply against 2 > consequent applications of annotate? > like 2 filter applied one-by-one can be different from one complex filter? > like: .annotate('purchases__quantity__sum').annotate('age__max') > and .annotate('purchases__quantity [The entire original message is not included] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
