Skip to content

Instantly share code, notes, and snippets.

@stephankaag
Created February 24, 2012 15:16
Show Gist options
  • Save stephankaag/1901565 to your computer and use it in GitHub Desktop.
Save stephankaag/1901565 to your computer and use it in GitHub Desktop.
DataMapper collection bug
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