# My number column returns boolean values

**URL:** <https://www.ruby-forum.com/t/my-number-column-returns-boolean-values/111197>\
**Category:** Rails\
**Created:** [August 3, 2007, 7:10pm UTC](https://www.ruby-forum.com/t/my-number-column-returns-boolean-values/111197 "2007-08-03T19:10:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![d.ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@d.ryan](https://www.ruby-forum.com/u/d.ryan)\
**Post date:** [August 3, 2007, 7:10pm UTC](https://www.ruby-forum.com/t/my-number-column-returns-boolean-values/111197/1 "2007-08-03T19:10:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![d.ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@d.ryan](https://www.ruby-forum.com/u/d.ryan)\
**Post date:** [August 3, 2007, 7:53pm UTC](https://www.ruby-forum.com/t/my-number-column-returns-boolean-values/111197/2 "2007-08-03T19:53:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![d.ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@d.ryan](https://www.ruby-forum.com/u/d.ryan)\
**Post date:** [August 3, 2007, 9:05pm UTC](https://www.ruby-forum.com/t/my-number-column-returns-boolean-values/111197/3 "2007-08-03T21:05:54Z")

</div>

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

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

ActiveRecord::ConnectionAdapters::OracleAdapter.emulate\_booleans =  
false
