Skip to content

Instantly share code, notes, and snippets.

@martinemde
Created December 29, 2009 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinemde/265618 to your computer and use it in GitHub Desktop.
Save martinemde/265618 to your computer and use it in GitHub Desktop.
diff --git a/lib/dm-core/query.rb b/lib/dm-core/query.rb
index 434d8ce..fb48204 100644
--- a/lib/dm-core/query.rb
+++ b/lib/dm-core/query.rb
@@ -1440,8 +1440,8 @@ module DataMapper
{
:child_key => keys,
:parent_key => keys,
- :child_repository_name => repository,
- :parent_repository_name => repository,
+ :child_repository_name => repository.name,
+ :parent_repository_name => repository.name,
}
end
require 'pp'
require 'do_sqlite3'
require 'dm-core'
DataMapper.setup(:default, 'sqlite3:///tmp/bs.db')
class Infestation
include DataMapper::Resource
property :id, Serial
belongs_to :sheep
belongs_to :flea
end
class Sheep
include DataMapper::Resource
property :id, Serial
property :name, String, :lazy => false
has n, :infestations
has n, :fleas, :through => :infestations
end
class Flea
include DataMapper::Resource
property :id, Serial
property :name, String, :lazy => false
has n, :infestations
has n, :sheeps, :through => :infestations
end
DataMapper.auto_migrate!
DataObjects::Sqlite3.logger = DataObjects::Logger.new(STDOUT, 0)
# now for the interesting stuff
s = Sheep.create(:name => 'Shaun')
s.fleas.new(:name => 'Fred')
s.fleas.new(:name => 'Frank')
s.save or raise "argh?"
@s = Sheep.first
puts "==========================="
puts "Flea.repositories is normal"
pp Flea.repositories
puts "@properties before we break it"
pp Flea.instance_variable_get("@properties")
puts "This screws up @properties on Flea"
(@s.fleas(:name => "Fred") - @s.fleas(:name => "Frank")).to_a
puts "This should not have the Repository as a key"
pp Flea.instance_variable_get("@properties")
puts "And accessing repositories will raise"
Flea.repositories # This raises
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment