[ruby-dbi-users] Mysql timestamp/datetime problem
Erik Hollensbe
erik at hollensbe.org
Tue Sep 30 10:45:04 EDT 2008
On Tuesday 30 September 2008 05:53:27 Georgios Moschovitis wrote:
> On my development machine, DBI select_all returns no rows if the table
> contains a timestamp or datetime column.
> If I drop the column, select_all returns rows.
>
> On my staging server, everything seems to work.
The email you sent me mentioned that this involves the default result, in the
working case, the default was null, in the failing case, the default
was '0000-00-00 00:00:00'
The problem with the latter case is that it can't be coerced to a DateTime
object because it's not a valid time... Honestly, I'm surprised mysql allows
it at all. Either way, you'll need to turn type conversion off (see
DBI.convert_types=) to get this default value to work or change it and all
occurrences of it in your database, or use bind_coltype to treat it as string
instead.
Hope this helps,
-Erik
More information about the ruby-dbi-users
mailing list