Opened 18 years ago

Closed 18 years ago

#1776 closed defect (fixed)

[patch] DateQuerySet broken when date field allows NULL

Reported by: Christopher Lenz <cmlenz@…> Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

…which also breaks the date_hierarchy feature for such a field.

Patch is trivial:

Index: django/db/models/query.py
===================================================================
--- django/db/models/query.py   (revision 393)
+++ django/db/models/query.py   (working copy)
@@ -478,7 +478,7 @@
         from django.db.backends.util import typecast_timestamp
         self._order_by = () # Clear this because it'll mess things up otherwise.
         if self._field.null:
-            date_query._where.append('%s.%s IS NOT NULL' % \
+            self._where.append('%s.%s IS NOT NULL' % \
                 (backend.quote_name(self.model._meta.db_table), backend.quote_name(self._field.column)))
         select, sql, params = self._get_sql_clause()
         sql = 'SELECT %s %s GROUP BY 1 ORDER BY 1 %s' % \

Change History (1)

comment:1 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

(In [2857]) Fixed #1776 -- Fixed bug in DateQuerySet when the field is null. Thanks, Christopher Lenz

Note: See TracTickets for help on using tickets.
Back to Top