diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py index 0cd393756d1..f00f1bd68a8 100644 --- a/django/db/models/sql/subqueries.py +++ b/django/db/models/sql/subqueries.py @@ -409,7 +409,7 @@ class DateQuery(Query): 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] diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index cf21d5210b7..ddac509ede7 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -755,10 +755,20 @@ Bug #6180, #6203 -- dates with limits and/or counts >>> 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)]