I tried to maintain backward compatibility in the best way possible - by 
keeping the old code in place if you don't need higher resolution. 

(Note, however, that there's a place in DAL where time() retains 
microseconds, and datetime does not, which was probably a bug -- in that 
case, I fixed it by retaining microseconds always)

As for my use case: The app in question gets a "forensic" event stream from 
other sources, which have millisecond timestamps. I need to give these back 
out when requested, and when searching, because it needs to correlate with 
logs in the event source. I don't manipulate the times, but I do need to 
retrieve them and use them for searches.

Up until now, I've passed them as strings to the table.insert() (in which 
case web2py does not interfere at all), and by configuring the driver to 
return datetime types in which case web2py doesn't format them (for sqlite, 
this is the 'PARSE_DECLTYPES' in driver_args that you've added a couple of 
months ago; psycopg does this automatically. 

However, I've been bitten two many times by forgetting to convert to str(); 
everything seems to work well, except that fractional seconds disappear, 
and it's really easy to overlook in testing. Which is why I did this patch.

Personally, I think that silent truncation IS a bug; I would have been 
happy with raising an Exception ("fractional seconds not supported"), but I 
don't like silent truncation.

unrelated: Would you be ok with turning foreign key checking on in sqlite3? 
It doesn't by default, which is a shame.

Reply via email to