Created
June 20, 2009 20:44
-
-
Save ashgti/133277 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!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