Menu

#165 orderBy: datetime.datetime cannot be compared with None

closed-works-for-me
None
5
2006-11-13
2006-03-28
Anonymous
No

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"

Discussion

  • Oleg Broytman

    Oleg Broytman - 2006-11-13

    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.

     
  • Oleg Broytman

    Oleg Broytman - 2006-11-13
    • labels: 519513 -->
    • assigned_to: nobody --> phd
    • status: open --> closed-works-for-me
     

Log in to post a comment.