summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-26 09:06:56 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-04-26 09:06:56 +0000
commitbb132aa3951c3d3582be608d9bb7af5a707bf6e6 (patch)
treebb842e6065bcb05af27006790c6017d45e6bdaf4
parentdd432cc94177f84e984b30f08ce473a8951ad8f7 (diff)
queryset-refactor: Repaired the dates() method with extra(select=...).xi
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
-rw-r--r--django/db/models/sql/subqueries.py3
-rw-r--r--tests/regressiontests/queries/models.py6
2 files changed, 7 insertions, 2 deletions
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py
index 385bbb3ae8..ea45ae2846 100644
--- a/django/db/models/sql/subqueries.py
+++ b/django/db/models/sql/subqueries.py
@@ -330,9 +330,10 @@ class DateQuery(Query):
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:
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index 6893ebc991..1e0e3398c8 100644
--- a/tests/regressiontests/queries/models.py
+++ b/tests/regressiontests/queries/models.py
@@ -586,7 +586,7 @@ Bug #6981
>>> 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()
@@ -598,6 +598,10 @@ Bug #6180, #6203
>>> 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()