Re: .dates() bug or feature?

2010-09-29 Thread dPeS
> Order matters when it comes to annotation.  Read this section very
> carefully:http://docs.djangoproject.com/en/dev/topics/db/aggregation/#order-of-...

Off course order matters, but in this case annotate adds some extra
field to each Rezerwacja object which is irrelevant to dates grouping
- the result is wrong, "year" grouping should give only one
datetime.datetime(2010, 1, 1, 0, 0) not 5 in this case.

d.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: .dates() bug or feature?

2010-09-28 Thread derek
On Sep 28, 12:08 pm, dPeS  wrote:
> Hi all,
>
> Anyone has explanation to this? :
>
> >>> len(models.Rezerwacja.objects.all())
> 9
> >>> len(models.Rezerwacja.objects.annotate(przyjazd=Min('transza__zajetosc__dzien')))
> 9
> >>> models.Rezerwacja.objects.annotate(przyjazd=Min('transza__zajetosc__dzien')).dates('utworzona','year')
>
> [datetime.datetime(2010, 1, 1, 0, 0), datetime.datetime(2010, 1, 1, 0,
> 0), datetime.datetime(2010, 1, 1, 0, 0), datetime.datetime(2010, 1, 1,
> 0, 0), datetime.datetime(2010, 1, 1, 0, 0)]
>
> I expect to get ONE datetime.datetime(2010, 1, 1, 0, 0) rather then 5
> which is |Min('transza__zajetosc__dzien')| ...
>
> tested on django 1.2.1
>
> Regards,
> d.
Order matters when it comes to annotation.  Read this section very
carefully:
http://docs.djangoproject.com/en/dev/topics/db/aggregation/#order-of-annotate-and-filter-clauses

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



.dates() bug or feature?

2010-09-28 Thread dPeS
Hi all,

Anyone has explanation to this? :

>>> len(models.Rezerwacja.objects.all())
9
>>> len(models.Rezerwacja.objects.annotate(przyjazd=Min('transza__zajetosc__dzien')))
9
>>> models.Rezerwacja.objects.annotate(przyjazd=Min('transza__zajetosc__dzien')).dates('utworzona','year')
[datetime.datetime(2010, 1, 1, 0, 0), datetime.datetime(2010, 1, 1, 0,
0), datetime.datetime(2010, 1, 1, 0, 0), datetime.datetime(2010, 1, 1,
0, 0), datetime.datetime(2010, 1, 1, 0, 0)]

I expect to get ONE datetime.datetime(2010, 1, 1, 0, 0) rather then 5
which is |Min('transza__zajetosc__dzien')| ...

tested on django 1.2.1

Regards,
d.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.