emulate_booleans for a specific connection

Hello, I'm running an environment with connections to different types of databases (using AR) in addition to the default mysql(5) connection. The MSSQL-Connections are working fine. Just one "old" 3rd party database makes problems: an old mysql(4) database. The problem is, that there are colums of type tinyint(1) which gets by default translated to boolean. As the mysql(5) environment uses the same connection adapter I cannot simply set emulate_booleans globally to false via environment.rb (somewhere the boolean mapping is used) . As all these 3rd party connections are established using establish_connection blocks I tried to set this there... but it seems to be ignored, as I'm still stopped with 'ArgumentError: binary columns cannot have a default value: "0"', which for my understanding should not occur when setting the emulation to false... Where's my fault? Or is it impossible to set this behavior (briefly said) Model/Connection wise ?!

Thanks for any idea!

Christian Meyer Web-Application-Developer

Hello, I'm running an environment with connections to different types of databases (using AR) in addition to the default mysql(5) connection. The MSSQL-Connections are working fine. Just one "old" 3rd party database makes problems: an old mysql(4) database. The problem is, that there are colums of type tinyint(1) which gets by default translated to boolean. As the mysql(5) environment uses the same connection adapter I cannot simply set emulate_booleans globally to false via environment.rb (somewhere the boolean mapping is used) . As all these 3rd party connections are established using establish_connection blocks I tried to set this there... but it seems to be ignored, as I'm still stopped with 'ArgumentError: binary columns cannot have a default value: "0"', which for my understanding should not occur when setting the emulation to false... Where's my fault? Or is it impossible to set this behavior (briefly said) Model/Connection wise ?!

Dumb suggestion:

class LegacyMysqlAdapter < ActiveRecord::ConnectionAdapters::MysqlAdapter   def self.emulate_booleans     false   ense end

then set the appropriate database connection's adapter to legacy_mysql

Fred

I already tried this kind of easy solution... but this fails as establish_connection from activerecord/lib/active_record/ connection_adapters/abstract/connection_specification.rb tries to load an gem with this name...

Christian Meyer

> then set the appropriate database connection's adapter to legacy_mysql

I already tried this kind of easy solution... but this fails as establish_connection from activerecord/lib/active_record/ connection_adapters/abstract/connection_specification.rb tries to load an gem with this name...

Then stick the above in a gem (and perhaps then vendor it into your app)

Fred