I've got an application that stores time of day and midnight
(00:00:00) is a valid time that sometimes needs to be stored and
retrieved.  That used to work fine in an old release of web2py but in
a recent release (1.84.4) such values are returned by DAL as None
value rather than datetime.time(0,0) as it should be.  This seems like
a defect to me.  Can it be fixed, or is there some reason for doing it
this way now?

I don't know when the change occurred.  It worked fine on 1.74.2.  It
no longer works the way I expect in 1.84.4.

I've tested with MySQL and sqlite and the problem only occurs when
using MySQL.  The time does display as 00:00:00 when I view it
directly in MySQL.  Something in DAL converts it to None.

Here is a test model:

db.define_table('test1',
    Field('start', 'time')
    )

Here are controller functions to populate and view some test data:

def populate():
    import datetime
    db.test1.insert(start=datetime.time(8, 30))
    db.test1.insert(start=datetime.time(0, 0))

def show():
    import sys
    items = db(db.test1.id > 0).select()
    sys.stderr.write(str(items) + "\n")
    return dict(items=items)

The latter writes the following to stderr:

test1.id,test1.start
1,08:30:00
2,<NULL>

Reply via email to