Description
Issue description
To be honest, I'm not sure what should happen, other than an error. But I don't think the current behavior (silently ignoring the problem) is okay because it results in incorrect output.
Basically the problem is MySQL supports storing impossible dates and times in DATETIME
and TIMESTAMP
columns. Obviously, this is terrible... but it is what it is at this point.
Go's time.Time
value doesn't support invalid dates and times, which is great, except it means there's nowhere for a datetime of 0000-00-00T00:00:00
to go.
Right now, go-sql-driver/mysql
converts both of these to Go's time.Time
zero value, which is the date time 0001-01-01T00:00:00
, which means sometimes people can get incorrect output.
My preference as a user is that the library returns an error if this condition is encountered. It would have been better if, originally, parseTime
caused some custom struct like mysql.Time
to be returned, which could at least indicate if there was a problem with parsing that particular datetime. Maybe we could add a new mode like parseMySQLTime
where this is possible?
But silently corrupting data is not okay! (Even if that data is stupid and wrong...)
Possibly related to #683? I didn't get any errors while parsing though, and I was able to parse every row.
Configuration
Driver version (or git SHA): a0583e0
Go version: go1.9.1 darwin/amd64
Server version: MySQL 5.6
Server OS: Ubuntu