Permalink
Browse files

Fixed #12242 -- Corrected a problem with masking extra selects() in a…

… DateQuerySet. Thanks to Alex Gaynor for his help debugging this one.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11748 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 7875421 commit 77755aa5a03ec7295d17149590829544aba71377 @freakboy3742 freakboy3742 committed Nov 19, 2009
Showing with 12 additions and 2 deletions.
  1. +1 −1 django/db/models/sql/subqueries.py
  2. +11 −1 tests/regressiontests/queries/models.py
@@ -409,7 +409,7 @@ def add_date_select(self, field, lookup_type, order='ASC'):
self.select = [select]
self.select_fields = [None]
self.select_related = False # See #7097.
- self.extra = {}
+ self.set_extra_mask([])
self.distinct = True
self.order_by = order == 'ASC' and [1] or [-1]
@@ -755,10 +755,20 @@ def __unicode__(self):
>>> Item.objects.dates('created', 'day')[0]
datetime.datetime(2007, 12, 19, 0, 0)
-Bug #7087 -- dates with extra select columns
+Bug #7087/#12242 -- 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)]
+>>> Item.objects.extra(select={'a': 1}).dates('created', 'day')
+[datetime.datetime(2007, 12, 19, 0, 0), datetime.datetime(2007, 12, 20, 0, 0)]
+
+>>> name="one"
+>>> Item.objects.dates('created', 'day').extra(where=['name=%s'], params=[name])
+[datetime.datetime(2007, 12, 19, 0, 0)]
+
+>>> Item.objects.extra(where=['name=%s'], params=[name]).dates('created', 'day')
+[datetime.datetime(2007, 12, 19, 0, 0)]
+
Bug #7155 -- nullable dates
>>> Item.objects.dates('modified', 'day')
[datetime.datetime(2007, 12, 19, 0, 0)]

0 comments on commit 77755aa

Please sign in to comment.