Invalid date in legacy database #184
Comments
I'm encountering this problem as well. I'm working with a WordPress MySQL database where WordPress decided "0000-00-00 00:00:00" would be a great default date, and when DataMapper encounters one of these records it raises the "invalid date" exception. |
Can ruby DateTime instances represent that date properly? Is DataMapper throwing that |
From what I can tell, Ruby's DateTime is causing the error. If I start an
|
I'd be happy with that behavior. |
JDBC driver for MySQL also allows to control this weirdness with "zeroDateTimeBehavior" property in connection string: http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html |
do_mysql 0.10.9 fixes 0-date issue in mysql (datamapper/do#37). |
I'm using DM to access a legacy MySQL database. One of the datetime columns frequently has values of 0000-00-00 00:00:00. When DM encounters one of these, I get an "invalid date" error. I would like to gracefully handle it instead. Here's the code that causes the error:
When I call
UserProfile.active
, it finds some of records with zeros for "profile_end" and gives the error. I would like to exclude these records altogether because if it has a profile_end of zeros, it's not an "active" record anyway.The text was updated successfully, but these errors were encountered: