Django

Code

Ticket #7155 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

dates() querysets don't work after qsrf

Reported by: fcaprioli@alice.it Assigned to: nobody
Milestone: 1.0 Component: Database layer (models, ORM)
Version: SVN Keywords: qsrf-cleanup post-qsrf
Cc: eric@ericwalstad.com, jdunck@gmail.com, jarek.zgoda@gmail.com Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by ramiro)

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

null_dates.patch (0.6 kB) - added by fcaprioli@alice.it on 05/02/08 12:57:20.
dates-qsrf-7155.diff (2.1 kB) - added by jdunck on 05/29/08 19:11:06.
Updated patch with regression test included.

Change History

05/02/08 12:57:20 changed by fcaprioli@alice.it

  • attachment null_dates.patch added.

05/02/08 14:17:48 changed by oyvind

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Spread across 3 tickets #7145, #7147

05/02/08 14:21:30 changed by Alex

  • needs_tests set to 1.
  • stage changed from Unreviewed to Accepted.

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.

05/06/08 18:53:24 changed by Eric Walstad <eric@ericwalstad.com>

  • cc set to eric@ericwalstad.com.

05/29/08 18:16:56 changed by anonymous

  • cc changed from eric@ericwalstad.com to eric@ericwalstad.com, jdunck@gmail.com.

05/29/08 19:11:06 changed by jdunck

  • attachment dates-qsrf-7155.diff added.

Updated patch with regression test included.

05/29/08 19:11:24 changed by jdunck

  • owner changed from nobody to jdunck.
  • status changed from new to assigned.
  • needs_tests deleted.

05/29/08 19:12:47 changed by jdunck

  • owner changed from jdunck to mtredinnick.
  • status changed from assigned to new.

05/29/08 19:13:06 changed by jdunck

  • owner changed from mtredinnick to nobody.

06/08/08 10:35:57 changed by fcaprioli@alice.it

  • stage changed from Accepted to Ready 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 :)

06/10/08 10:55:47 changed by gav

  • keywords changed from post-qsrf to qsrf-cleanup post-qsrf.
  • stage changed from Ready for checkin to Accepted.

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

06/14/08 23:03:32 changed by Karen Tracey <kmtracey@gmail.com>

#7199 marked as a dup of this.

06/14/08 23:16:46 changed by Karen Tracey <kmtracey@gmail.com>

  • stage changed from Accepted to Ready 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.

06/16/08 11:24:34 changed by ramiro

  • description changed.

06/16/08 12:10:45 changed by jacob

  • milestone set to 1.0.

06/23/08 02:11:32 changed by zgoda

  • cc changed from eric@ericwalstad.com, jdunck@gmail.com to eric@ericwalstad.com, jdunck@gmail.com, jarek.zgoda@gmail.com.

06/25/08 08:38:07 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #7155 (dates() querysets don't work after qsrf)




Change Properties
Action