
creating models from their relationship chains does not respect repository
Reported by Alex Arnell | July 24th, 2008 @ 03:51 PM
If the following two repositories and relationship are used
DataMapper.setup(:default, 'mysql://localhost/dm_core_test')
DataMapper.setup(:external, 'mysql://someother_host/dm_core_test')
class Post
has n, :comments
end
class Comment
belongs_to :post
end
The following will not store the comments in the external repository.
repository(:external) do
Post.first.comments.create( ... )
end
Instead you must do something like this,
repository(:external) do
Comment.create( :post => Post.first, ... )
end
Comments and changes to this ticket
-
Dan Kubb (dkubb) December 4th, 2008 @ 03:33 AM
- Assigned user cleared.
- State changed from new to confirmed
I can confirm this is currently an issue in sam/dm-core and dkubb/dm-core.
-
Dan Kubb (dkubb) January 8th, 2009 @ 04:42 AM
- State changed from confirmed to accepted
- Assigned user set to Dan Kubb (dkubb)
-
Dan Kubb (dkubb) February 21st, 2009 @ 04:16 AM
Alex, I'm trying to wrap my head around one detail not shown in your bug report. Was the Post created in the :default repository or the :external repository? That's the only thing I am unclear on.
For now I'm going to assume that the Post was created in the external repository, since if you did Post.first the external repo block you would've gotten nil.
Attached is a script which reproduces the issue based on this assumption. I used it with dm-core/next and can confirm it is still a problem. (although I did expect it to be resolved)
-
Dan Kubb (dkubb) November 10th, 2009 @ 01:35 AM
- State changed from accepted to resolved
I can confirm that my attached script now passes with edge dm-core.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »