Reading date '0000-00-00' from db results in conversion exception

Bug #438857 reported by analogue
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Connector/Python
Fix Released
Medium
Geert JM Vanderkelen

Bug Description

A date value of 0000-00-00 is apparently valid in mysql. When attempting to read this value from the db, a conversion exception is thrown.

'Could not convert '0000-00-00' to python datetime.date'

From a compatibility perspective, the MySQLdb python bindings which uses the native _mysql.so handles this fine and returns the earliest date possible. Something like '1970-01-01' I think.

I would be nice when dropping in the pure python implementation, that it would behave the same as the native version of the python bindings.

Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

Yes, but return 1970-01-01 is also wrong. That's incorrect data.
I'll check this further out. We have to return something, but the year 0000 is not 1970 :)

Thanks for the report!

Changed in myconnpy:
importance: Undecided → High
assignee: nobody → Geert JM Vanderkelen (geertjmvdk)
importance: High → Medium
Revision history for this message
Geert JM Vanderkelen (geertjmvdk) wrote :

MySQLdb returns None for DATETIME columns set to '0000-00-00 00:00:00' and DATE set to '0000-00-00'.

I'm going to follow that and make sure that we follow MySQL specifications, just like MySQLdb appears to be doing, which is good!

http://dev.mysql.com/doc/refman/5.1/en/datetime.html

Changed in myconnpy:
status: New → In Progress
Changed in myconnpy:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.