My number column returns boolean values

Hi everyone,

I’m working on a new rails project and have to build it on top of a
legacy oracle database. I’m trying to figure out how to get the
number value from a NUMBER(1) datatype. So far I’m only getting a
“true” value for 1 and “false” for any other number. From the console
I can print out my object values and can see that there are number
values in the object, but whenever I try to access the value from a
method, it converts to boolean. Is there a way to force the method to
return the actual number value?

Look in oracle_adapter.rb (it should be in your vendor/ directory if
you’ve forzen rails) and you’ll notice that it specifically maps, if
my memory of Oracle and AR don’t fail me, NUMBER(1)'s to boolean
values because the built-in Oracle boolean field (is there one? that I
cannot remember) is not supported at current. It also does some funky
mapping with DATE columns regarding 00:00:00 as the time portion. Be
careful with rails and Oracle they work great if you know the caveats
but they can bite you if you don’t.

It should be noted I haven’t written a line of ruby in almost six
months so my knowledge is dated.

Thanks for the quick response Chris! You pointed me in the right

I had to add this line to the environment.rb file:

ActiveRecord::ConnectionAdapters::OracleAdapter.emulate_booleans =