Menu

#272 timedelta doesnt convert properly

MySQLdb-1.2
open
MySQLdb (285)
5
2012-09-19
2008-11-19
nassrat
No

Version 1.2.2, timedelta blindly converts timedeltas. MySQL version 4 max TIME max days = 34.

datetime.timedelta(hours=-839, minutes=-59, seconds=-59) using the convert function "'-35 0:0:1'" which is out of bounds for mysql

Discussion

  • nassrat

    nassrat - 2008-11-19

    In [111]: f(datetime.timedelta(hours=-817), None)

    Out[111]: "'-35 23:0:0'"

    ALSO INVALID!!!

     
  • Andy Dustman

    Andy Dustman - 2009-03-11

    So what do we do about it, considering it's a limitation in the field type?

     
  • nassrat

    nassrat - 2009-03-11

    Its not the limitation part that I was complaining about, but rather that the value datetime.timedelta(hours=-839, minutes=-59, seconds=-59) is within the bounds of MySQL. (When I said max days = 34, I meant < 35), so basically MySQLDB should try to insert "-34 11:59:59" rather than "-35 0:0:1".

    The reason why MySQLDB did "-35 0:0:1" is I think because thats what python does when you stringify that specific timedelta. There MySQL should take care of those boundry cases mentioned in the body and other comment.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.