Relationship trouble

Skip to first unread message


Nov 6, 2008, 12:08:37 PM11/6/08
to DataMapper
Hello data mappers,

I've been having some relationship issues for a while now. With the
DataMapper kind of relationship, I mean. The problem is that #first
behaves strangely when used with an association whose parent objet is
part of a collection, or something like that.

Please have a look at the following example:

I think the underlying reason for this strangeness might be that
Relationship#get_children is not adapting its query_values correctly
when finder = :first, but the implementation of that method is a bit
of a mystery to me, so I wouldn't know for sure. Any ideas?


Dan Kubb (dkubb)

Nov 6, 2008, 6:59:31 PM11/6/08
to DataMapper
Hi Erik,

I can verify this is a problem, even in the dkubb/dm-core fork. It
has to do with the way OneToMany::Proxy#first is implemented to handle
one-to-many associations as well as many to many associations. IMHO
this was probably not the best approach, it would've been better to
push the many-to-many logic to the ManyToMany::Proxy object instead.
I think that ultimately this is what will end up happening, unless we
are able to factor the code out and just use what's implemented in
Collection.. which is the ideal end result.

For now you should post a ticket at Lighthouse (http:// so that it can be fixed in dm-



Nov 6, 2008, 10:06:53 PM11/6/08
to DataMapper
On 7 Nov, 00:59, "Dan Kubb (dkubb)" <> wrote:
> For now you should post a ticket at Lighthouse (http://
> so that it can be fixed in dm-
> core.

Thanks for the response. Ticket posted:
Reply all
Reply to author
0 new messages