ActiveRecord Question: Disabling Boolean Emulation

Hello everyone, I've got a question for the ActiveRecord gurus.

ActiveRecord version: 2.3.4
ActiveRecord adapter: mysql

I'm accessing a database originally designed as the back-end data-
store for a Microsoft Access-based GUI application (using "linked"
tables). MS Access, if using linked tables to use a MySQL database
wants its boolean fields, like ActiveRecord, to by TINYINT(1) fields.
However, is makes the field "signed" and uses 0 for false and -1 for

I've taken several approaches to interfacing with boolean fields in
this database in an interoperable way (keeping boolean true values as
-1). What seems like it should be so easy/simple has yet yield a clean
solution (to me at least).

My Example Table (tblImages):


ActiveRecord class:

class Image < ActiveRecord::Base
  set_table_name 'tblImages'
  set_primary_key 'ImageID'
  def fixed
    self.IsFixed_before_type_cast == "-1"
  def fixed=(val)
    self[:IsFixed] = (val ? '-1' : '0')

The above code is just one of the many approaches I've taken. I always
get so close yet so far. Reading the value is easy by getting it prior
to type-casting and interpreting it how I want. However, coercing
ActiveRecord (and the MySQL adapter) to issue an "UPDATE tblImage SET
IsFixed = -1 ..." seem all but impossible when I issue a save! on an

So, is there any way to tell ActiveRecord (or the MySQL adapter) to
simply disable its boolean emulation on a given field (or even the
whole table or database)? Or, does anyone have any alternate ideas
that might work instead or even better?

Thanks for your help!

Why? How are you trying and why does it fail?

You can easily change the values in a before_save filter.

I believe you can do that in the adapter itself. You should be able to
find it under your activerecord folder (in my PC: C:\ruby\lib\ruby\gems
\mysql_adapter.rb). Look for "class MysqlAdapter < AbstractAdapter" in
the code and you'll see this line:

      self.emulate_booleans = true

Change the line to:

      self.emulate_booleans = false

and see what happens.