Opened 17 years ago

Closed 17 years ago

Last modified 13 years ago

#7155 closed (fixed)

dates() querysets don't work after qsrf

Reported by: fcaprioli@… Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: qsrf-cleanup post-qsrf
Cc: eric@…, jdunck@…, jarek.zgoda@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Ramiro Morales)

After queryset refactor merge, a .dates() DateQueryset won't work on a null=True DateField.

During query setup, the queryset adds a .filter(fieldname__isnull=True) instead of .filter(fieldname__isnull=False) to avoid parsing null dates, so the resulting sql returns an empty list (or raise errors if there actually are null fields in the db).

I've attached a patch that fixes the problem

Attachments (2)

null_dates.patch (592 bytes ) - added by fcaprioli@… 17 years ago.
dates-qsrf-7155.diff (2.1 KB ) - added by Jeremy Dunck 17 years ago.
Updated patch with regression test included.

Download all attachments as: .zip

Change History (18)

by fcaprioli@…, 17 years ago

Attachment: null_dates.patch added

comment:1 by oyvind, 17 years ago

Spread across 3 tickets #7145, #7147

comment:2 by Alex Gaynor, 17 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

I'm marking this as accepted, and the patch makes sense, however it would be nice if we could add a testcase for this regression.

comment:3 by Eric Walstad <eric@…>, 17 years ago

Cc: eric@… added

comment:4 by anonymous, 17 years ago

Cc: jdunck@… added

by Jeremy Dunck, 17 years ago

Attachment: dates-qsrf-7155.diff added

Updated patch with regression test included.

comment:5 by Jeremy Dunck, 17 years ago

Needs tests: unset
Owner: changed from nobody to Jeremy Dunck
Status: newassigned

comment:6 by Jeremy Dunck, 17 years ago

Owner: changed from Jeremy Dunck to Malcolm Tredinnick
Status: assignednew

comment:7 by Jeremy Dunck, 17 years ago

Owner: changed from Malcolm Tredinnick to nobody

comment:8 by fcaprioli@…, 17 years ago

Triage Stage: AcceptedReady for checkin

I've been using the patched code in a fairly complex app (production server, a few million pages etc) without any problem; now that it includes tests (thank you jeremy!), this can be probably checked in even before malcolm's return. Any core dev interested? It is, after all, an harmless on-liner :)

comment:9 by George Vilches, 17 years ago

Keywords: qsrf-cleanup added
Triage Stage: Ready for checkinAccepted

Non-core devs should not mark things as ready for checkin.

comment:10 by Karen Tracey <kmtracey@…>, 17 years ago

#7199 marked as a dup of this.

comment:11 by Karen Tracey <kmtracey@…>, 17 years ago

Triage Stage: AcceptedReady for checkin

Bumping back up to ready for checkin based on Russell's note to django-dev:

http://groups.google.com/group/django-developers/msg/e8762784813b3921

where he says "If a ticket describes something that is clearly a bug, move to accepted (or ready for checkin if it's a trivial problem with a patch and tests ready to go)."

I think this one fits the "trivial" category and it has a test. It looks like at least 4 people have hit this bug and reported it in the tracker so it would be nice to have the very minor and obvious fix get into the code base.

comment:12 by Ramiro Morales, 17 years ago

Description: modified (diff)

comment:13 by Jacob, 17 years ago

milestone: 1.0

comment:14 by Jarek Zgoda, 17 years ago

Cc: jarek.zgoda@… added

comment:15 by Russell Keith-Magee, 17 years ago

Resolution: fixed
Status: newclosed

(In [7739]) Fixed #7155 -- Corrected DateQuerySet to handle nullable fields. Thanks to fcaprioli@… for the original report and patch, and to Jeremy Dunck for the test case.

comment:16 by Jacob, 13 years ago

milestone: 1.0

Milestone 1.0 deleted

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