This is for DBI:ODBC, which activerecord-sqlserver-adapter uses.
Discussion here:
http://groups.google.com/group/rails-sqlserver-adapter/browse_thread/thread/7c75c7c87418d5e0
The change in dbi.rb here:
http://github.com/erikh/ruby-dbi/commit/e7f7fcbff57f79da9ff5b99c702ea9d77c06cedb
..coerces TINYINT to BOOL, even when the TINYINT is an 8-bit number. This is rarely what you'd want with MSSQL since
it has a BIT data type.
The MYSQL adapter makes use of an emulate_booleans option to control this kind of conversion, and turns it off
by default:
http://osdir.com/ml/RubyonRailsTalk/2009-10/msg00160.html
My Rails 2.3.4 is using DBI 0.4.1.
Here's a patch which treats TINYINT as an INTEGER, which works for my purposes.
For this file on my system:
/usr/lib/ruby/gems/1.8/gems/dbi-0.4.1/lib/dbi/typeutil.rb
--- typeutil.rb 2009-10-13 09:25:02.000000000 +0200
+++ typeutil_les.rb 2009-10-13 09:27:50.000000000 +0200
@@ -63,13 +63,13 @@
#
def self.type_name_to_module(type_name)
case type_name
- when /^int(?:\d+|eger)?$/i
+ when /^int(?:\d+|eger)?$/i, /^tinyint$/i
DBI::Type::Integer
when /^varchar$/i, /^character varying$/i
DBI::Type::Varchar
when /^(?:float|real)$/i
DBI::Type::Float
- when /^bool(?:ean)?$/i, /^tinyint$/i
+ when /^bool(?:ean)?$/i
DBI::Type::Boolean
when /^time(?:stamp(?:tz)?)?$/i
DBI::Type::Timestamp
|