Relationship trouble

0 views
Skip to first unread message

crantz

unread,
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:
http://pastie.org/308772

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?

Erik

Dan Kubb (dkubb)

unread,
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://
wm.lighthouseapp.com/projects/4819/) so that it can be fixed in dm-
core.

Dan

crantz

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

Thanks for the response. Ticket posted:
<http://wm.lighthouseapp.com/projects/4819-datamapper/tickets/643-
associations-and-first-incorrect-result>
Reply all
Reply to author
Forward
0 new messages