Django

Code

Ticket #1062 (closed: fixed)

Opened 3 years ago

Last modified 3 years ago

[patch] typecast on date fails

Reported by: cmaloney@cardgate.net Assigned to: adrian
Milestone: Component: Database layer (models, ORM)
Version: SVN Keywords:
Cc: nesh@studioquattro.co.yu Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

When using date based generic views with SQLite, the following error occurrs:

Exception Type: ValueError? Exception Value: need more than 1 value to unpack Exception Location: /usr/local/lib/python2.4/site-packages/django/core/db/typecasts.py in typecast_timestamp, line 22

It seems the typecast for date assumes date+time, whereas the DateField?() comes back with only a date. I have worked around this problem using the following patch:

--- typecasts.py 2005-10-21 11:11:48.000000000 +1000 +++ /usr/lib/python2.4/site-packages/Django-0.90-py2.4.egg/django/core/db/typecasts.py 2005-12-14 12:57:53.000000000 +1100 @@ -20,7 +20,11 @@

# "2005-07-29 15:48:00.590358-05" # "2005-07-29 09:56:00-05" if not s: return None

+ try:

d, t = s.split()

+ except ValueError?: + d = s + t = '00:00:01'

# Extract timezone information, if it exists. Currently we just throw # it away, but in the future we may make use of it. if '-' in t:

Attachments

typecast.diff (0.5 kB) - added by Nebojša Đorđević - nesh <nesh@studioquattro.co.yu> on 01/09/06 07:17:51.
slightly different patch

Change History

12/14/05 17:01:31 changed by anonymous

  • version set to SVN.

01/09/06 07:09:51 changed by Nebojša Đorđević - nesh <nesh@studioquattro.co.yu>

  • cc set to nesh@studioquattro.co.yu.

01/09/06 07:17:51 changed by Nebojša Đorđević - nesh <nesh@studioquattro.co.yu>

  • attachment typecast.diff added.

slightly different patch

01/09/06 07:25:39 changed by Nebojša Đorđević - nesh <nesh@studioquattro.co.yu>

  • summary changed from typecast on date fails to [patch] typecast on date fails.

Another sollution is to not use DateField alltogether, use only DateTimeField which works OK.

01/14/06 23:54:48 changed by adrian

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

(In [1971]) Fixed #1062 -- Fixed database typecasting bug for DateTimeFields? in SQLite. Thanks, Nesh and cmaloney


Add/Change #1062 ([patch] typecast on date fails)




Change Properties
Action