Skip to content

Instantly share code, notes, and snippets.

@ashgti
Created June 20, 2009 20:44
Show Gist options
  • Select an option

  • Save ashgti/133277 to your computer and use it in GitHub Desktop.

Select an option

Save ashgti/133277 to your computer and use it in GitHub Desktop.
#!ruby
require 'rubygems'
require 'dm-core'
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "mysql://root:password@localhost/db_testing")
class Car
include DataMapper::Resource
property :id, Serial
property :miles, BigDecimal, :scale => 2, :precision => 14
end
Car.auto_migrate!
a = Car.new
a.miles = 50.5
a.save
p Car.all(:miles => 50.5) #=> [], should not be empty
p Car.all(:conditions => ['miles = ?', 50.5]) #=> [#<Car @id=1 @miles=#<BigDecimal:1237bd8,'0.505E2',8(8)>>]
p Car.all(:conditions => ['miles = ?', 50.5]) == Car.all(:miles => 50.5) #=> false, should be true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment