hi, I am having some problem here with field Decimal

My Class:

require 'dm-core'

class Registry
  include DataMapper::Resource

  property :num, Decimal, :key => true,  :precision => 20, :scale => 0
end

require 'dm-migrations'
DataMapper.finalize
DataMapper.setup(:default, 'sqlite::memory:')
DataMapper.auto_migrate!

My Test:

// I start irb
$ irb -r ./dm
/home/arthur/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/yaml.rb:56:in
`<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your
ruby.

// and create a new registry
ruby-1.9.3-p0 :001 > r = Registry.new(:num => 321512420108210029)
 => #<Registry @num=#<BigDecimal:9771c54,'0.3215124201 08210029E18',
18(27)>>  // bigdecimal is showing correct num
ruby-1.9.3-p0 :002 > r.save
 => true
ruby-1.9.3-p0 :003 > Registry.all
 => [#<Registry @num=#<BigDecimal:98358e8,'0.3215124201 08210048E18',
18(27)>>] // num is wrong
ruby-1.9.3-p0 :004 >
Registry.all.first.num.to_i                                                     
        //
trying to convert to int
 =>
321512420108210048                                                              
                            //
wrong value
ruby-1.9.3-p0 :005 >
BigDecimal.new(321512420108210029).to_i                                //
here, aparently bigdecimal is working correct
 => 321512420108210029

Anyone can help me ? What am I doing wrong ?
I try too on mysql, and I have the same problem.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to datamapper@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to