# Database default value problem

**URL:** <https://www.ruby-forum.com/t/database-default-value-problem/147554>\
**Category:** Rails\
**Created:** [September 3, 2008, 3:16am UTC](https://www.ruby-forum.com/t/database-default-value-problem/147554 "2008-09-03T03:16:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pepe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/4da419/32.png) [@pepe](https://www.ruby-forum.com/u/pepe)\
**Post date:** [September 3, 2008, 3:16am UTC](https://www.ruby-forum.com/t/database-default-value-problem/147554/1 "2008-09-03T03:16:57Z")

</div>

Hello.

I am running into an issue I would like to know if there is a solution  
for. I am running Ruby version 1.8.6 and Rails 1.2.3. My database is  
Oracle (10g) and I have one field defined as:

MY\_FIELD NUMBER(1,0) DEFAULT ‘2’

When a record is created in the database the value that invariable  
gets posted to the table is 0 (zero) instead of 2. However, if I  
change the field to:

MY\_FIELD NUMBER(2,0) DEFAULT ‘2’, the default value of 2 is correctly  
posted.

I have the feeling that Ruby and/or Rails are considering the  
NUMBER(1,0) field as a true/false container and anything that is not a  
1 (true) will be converted to a 0 (false), including the default  
value.

Any ideas why this is happening and/or how to solve it short or  
modifying the column’s length?

Thanks in advance.

Pepe
