Forum: Ruby Bug in DBI::ODBC: DateTime treated as Date

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
David B. (Guest)
on 2009-01-10 14:35
Using DBI::ODBC and it works nicely thank you.

Inserting a value into a column of type SQL datetime.

If the value is ruby type DateTime, it gets truncated to a Date on
insert. The time portion is lost.

eg 2009-10-01T21:37:14 => 2009-10-01 00:00:00.

I think the bug may be in function register_conversion around line 69 in
odbc.rb. In the case statement, since DateTime is a subclass of Date,
the Date branch is taken instead of the DateTime branch.

The fix may be as simple as re-ordering the case branches.

Anyone familiar with the code willing to comment? I'm new to ruby, so
I'd appreciate it.
This topic is locked and can not be replied to.