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

On Jan 12, 11:25Â pm, nerd [email protected] wrote:

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

On 13 Jan., 11:57, Frederick C. [email protected]
wrote:

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

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

On Jan 14, 1:06Â pm, nerd [email protected] wrote:

On 13 Jan., 11:57, Frederick C. [email protected]
wrote:

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