Roundup Tracker - Issues

Message5008

Author tekberg
Recipients tekberg
Date 2014-03-10.16:17:29
Message-id <1394468250.07.0.493654913053.issue2550834@psf.upfronthosting.co.za>
In-reply-to
I'm beginning to think that nobody uses postgres as back end since I have 
already found 3 (2550805, 2550829, and this) things that work differently 
between the sqlite3 and postgres. This one is the handling of Date() 
attributes in a class like issue. The 2 Date attributes in the issue class 
(creation, activity) always have non-None values. However if one adds a 
Date() (call it target_date) attribute most of the time it works fine. If 
one does a search where the 'group by' uses target_date that also works  
fine if all of the target_dates have Date values. However if one of the 
target_dates is None (NULL in the DB), one gets an error. The following is 
the last line of the stack trace and the error.

 File "/usr/local/lib/python2.7/site-packages/roundup/hyperdb.py", line 
552, in _sort
    sortattr = sorted (sortattr, key = lambda x:x[i:idx], reverse = rev)
TypeError: can't compare datetime.datetime to NoneType

If I look at postgres, target_date is defined as 'timestamp without time 
zone'. The target_date is defined by sqlite3 as a VARCHAR(30). If I use 
sorted with None and strings it works:

>>> a = ['a','b',None,'c']
>>> sorted(a)
[None, 'a', 'b', 'c']

In an earlier run I dumped sortattr to a file and found that 
datetime.datetime was the data type being used. Using sorted with None and 
datetime.datetime objects one gets an error.

>>> import datetime
>>> b = [datetime.datetime(2014,1,1), datetime.datetime(2013,1,1), None, 
datetime.datetime(2012,1,1)]
>>> sorted(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't compare datetime.datetime to NoneType

This is the same error that roundup gets.

I don't have a good fix for this yet.
History
Date User Action Args
2014-03-10 16:17:30tekbergsetrecipients: + tekberg
2014-03-10 16:17:30tekbergsetmessageid: <1394468250.07.0.493654913053.issue2550834@psf.upfronthosting.co.za>
2014-03-10 16:17:29tekberglinkissue2550834 messages
2014-03-10 16:17:29tekbergcreate