Skip to content

Commit

Permalink
queryset-refactor: Repaired the dates() method with extra(select=...).xi
Browse files Browse the repository at this point in the history
It was broken by [7340]. Patch from Ian Kelly. Fixed #7087.


git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7468 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Apr 26, 2008
1 parent dd432cc commit bb132aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion django/db/models/sql/subqueries.py
Expand Up @@ -330,9 +330,10 @@ def results_iter(self):
from django.db.backends.util import typecast_timestamp
needs_string_cast = self.connection.features.needs_datetime_string_cast

offset = len(self.extra_select)
for rows in self.execute_sql(MULTI):
for row in rows:
date = row[0]
date = row[offset]
if resolve_columns:
date = self.resolve_columns([date], fields)[0]
elif needs_string_cast:
Expand Down
6 changes: 5 additions & 1 deletion tests/regressiontests/queries/models.py
Expand Up @@ -586,7 +586,7 @@ class Meta:
>>> Tag.objects.select_related('parent').order_by('name')
[<Tag: t1>, <Tag: t2>, <Tag: t3>, <Tag: t4>, <Tag: t5>]
Bug #6180, #6203
Bug #6180, #6203 -- dates with limits and/or counts
>>> Item.objects.count()
4
>>> Item.objects.dates('created', 'month').count()
Expand All @@ -598,6 +598,10 @@ class Meta:
>>> Item.objects.dates('created', 'day')[0]
datetime.datetime(2007, 12, 19, 0, 0)
Bug #7087 -- dates with extra select columns
>>> Item.objects.dates('created', 'day').extra(select={'a': 1})
[datetime.datetime(2007, 12, 19, 0, 0), datetime.datetime(2007, 12, 20, 0, 0)]
Test that parallel iterators work.
>>> qs = Tag.objects.all()
Expand Down

0 comments on commit bb132aa

Please sign in to comment.