# Object class for default mysql :decimal columns

**URL:** <https://www.ruby-forum.com/t/object-class-for-default-mysql-decimal-columns/107555>\
**Category:** Rails\
**Created:** [June 23, 2007, 2:50am UTC](https://www.ruby-forum.com/t/object-class-for-default-mysql-decimal-columns/107555 "2007-06-23T02:50:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjnkns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c5a1d2/32.png) [@cjnkns](https://www.ruby-forum.com/u/cjnkns)\
**Post date:** [June 23, 2007, 2:50am UTC](https://www.ruby-forum.com/t/object-class-for-default-mysql-decimal-columns/107555/1 "2007-06-23T02:50:55Z")

</div>

I’ve noticed some strange behavior while debugging some problems in the  
acts\_as\_rated plugin and Rails 1.2.3 with mysql.

In a migration or schema, a :decimal column that specifies :scale is  
returned as a BigDecimal object in Rails. That’s good.

Specifying just :decimal however without :scale or :precision will  
return a Fixnum object in Rails. That’s bad and inconsistent. For  
:decimal data, developers would expect to be able to use methods like  
nan? that only work for numeric classes such as Float or BigDecimal.  
Columns of type :decimal should return a consistent object class no  
matter what the scale or precision defined.

Can anyone confirm this or shed some light? I hesitate to submit a Rails  
bug because I have no idea how to go about writing a test for this  
within Rails.

Thanks!

---

<div class="post-metadata">

**Author:** ![cjnkns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c5a1d2/32.png) [@cjnkns](https://www.ruby-forum.com/u/cjnkns)\
**Post date:** [June 23, 2007, 2:54am UTC](https://www.ruby-forum.com/t/object-class-for-default-mysql-decimal-columns/107555/2 "2007-06-23T02:54:56Z")

</div>

I don’t have time to confirm right now, but go ahead and put the bug  
in. The worst that happens is they close it.

On 6/22/07, Carl J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> nan? that only work for numeric classes such as Float or BigDecimal.  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Gabe da Silveira  
[http://darwinweb.net](http://darwinweb.net)
