#12242: DateQuerySet doesn't correctly mask extra selects ------------------------------------------+--------------------------------- Reporter: russellm | Owner: nobody Status: new | Milestone: 1.2 Component: Database layer (models, ORM) | Version: 1.1 Keywords: | Stage: Unreviewed Has_patch: 0 | ------------------------------------------+--------------------------------- DateQuerySet doesn't interact well with extra.
Line 412 of sql/subqueries.sql explicitly clears *all* of the extra clause, including any Where clause. However, any extra clause following the dates() clause will be left untouched. The practical side effect of this is that there is a test in regressiontests/queries that will fail depending on database order. The test checks: {{{ Item.objects.dates('created', 'day').extra(select={'a': 1}).query }}} will result in the SQL {{{ SELECT DISTINCT (1) AS "a", DATE_TRUNC('day', "myapp_item"."created") FROM "myapp_item" ORDER BY 1 ASC }}} Which means that the ordering is done on (1), not on the date. It also means that any extra WHERE clause mentioned prior to the dates clause will not be processed. The solution here should be to set the extra_select mask, rather than clearing the extra clause. -- Ticket URL: <http://code.djangoproject.com/ticket/12242> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=.