Skip to content

Instantly share code, notes, and snippets.

@eltiare
Created October 3, 2008 16:13
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 eltiare/14575 to your computer and use it in GitHub Desktop.
Save eltiare/14575 to your computer and use it in GitHub Desktop.
# In DM 0.9.7 ...
class Test
include DataMapper::Resource
property :id, Integer, :serial => true
property :parent_id, Integer, :index => true
has_1 :child, :class_name => 'Test', :parent_key => [:id], :child_key => [:parent_id]
end
t = Test.new
t.save
t2 = Test.new(:parent_id => t.id)
t2.save
t.reload
t.child.child # This *should* be nil, but comes out to the same as t.child
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment