When datetime.datetime is used for DateTimeCols:
Using defaultOrder with a DateTimeCol fails when there
is an empty DateTimeCol (None). This does not happen
with the mx modules.
"can't compare datetime.time to NoneType" raised if one
tries to list(Test.select()).sort(key=attrgetter("dt")), but
that's not an SQLObject-related problem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=4799
I cannot reproduce the problem. The following program works
fine for me.
#! /usr/local/bin/python
from sqlobject import *
__connection__ = "sqlite:/:memory:?debug=1"
class Test(SQLObject):
class sqlmeta:
defaultOrder = "dt"
name = StringCol(default=None)
dt = DateTimeCol(default=None)
from datetime import datetime
Test.createTable()
Test(name="test1")
Test(name="test2", dt=datetime(1967, 12, 21))
Test(dt=datetime(1984, 5, 21))
print list(Test.select())
"can't compare datetime.time to NoneType" raised if one
tries to list(Test.select()).sort(key=attrgetter("dt")), but
that's not an SQLObject-related problem.