Opened 17 years ago

Last modified 13 years ago

#7155 closed

dates() querysets don't work after qsrf — at Version 12

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

Change History (14)

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, 16 years ago

Cc: jdunck@… added

by Jeremy Dunck, 16 years ago

Attachment: dates-qsrf-7155.diff added

Updated patch with regression test included.

comment:5 by Jeremy Dunck, 16 years ago

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

comment:6 by Jeremy Dunck, 16 years ago

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

comment:7 by Jeremy Dunck, 16 years ago

Owner: changed from Malcolm Tredinnick to nobody

comment:8 by fcaprioli@…, 16 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, 16 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@…>, 16 years ago

#7199 marked as a dup of this.

comment:11 by Karen Tracey <kmtracey@…>, 16 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, 16 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top