Created
February 24, 2012 15:16
-
-
Save stephankaag/1901565 to your computer and use it in GitHub Desktop.
DataMapper collection bug
This file contains 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
require 'rubygems' | |
dm_version = "=1.2.0" | |
gem "dm-core", dm_version | |
require 'dm-core' | |
gem "dm-migrations", dm_version | |
require 'dm-migrations' | |
class Thing | |
include DataMapper::Resource | |
property :id, Serial, :key => true | |
has n, :tags | |
end | |
class Tag | |
include DataMapper::Resource | |
property :id, Serial, :key => true | |
belongs_to :thing | |
end | |
DataMapper.finalize | |
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/test.sqlite3") | |
DataMapper.auto_migrate! | |
thing = Thing.create | |
thing.tags.create | |
tag = thing.tags.first | |
if thing.tags.size == 1 | |
puts "OK" | |
else | |
raise "Expected 1 tag got #{thing.tags.size}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment