[Dbix-class] introspection/reflection - finding the 'many to many' relationships of a ResultSource

John Napiorkowski jjn1056 at yahoo.com
Fri May 25 18:59:51 GMT 2007


--- Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:

> Last time I've started this subject I tried to
> propose some solutions
> - but unfortunately my understanding of the DBIC
> internals was not
> enough to propose anything valid.  So perhaps I'll
> try  it differently
> this time.
> 
> I need to discover all the relationships of a
> ResultSource class.  I
> can list all of the 'normal' relations by calling
> ->relationships and
> then check their attributes with
> ->relationship_info, but this is not
> possible with the many_to_many relationships.  Are
> there any plans to
> make this discovery possible?  I don't know if it
> should be done with
> the same methods or with something different - what
> I need is just any
> way of doing that.
> 
> -- 
> Zbigniew Lukasiak
> http://brudnopis.blogspot.com/

It would be good to have additional metadata about the
relationships.  I've run into this with the
bulk_create branch work I'm trying to complete, since
I'd like an easy way to determine the relationship
type in terms of belongs_to, has_many, etc.

A lot of my databases have many_to_many relationships
and I've found some weirdness with edge case stuff,
like when a table has a M2M with itself and the FK's
in the relating table have role names different from
the PK name.  I haven't complained about it so much
because I haven't had time to write up a good set of
tests to demonstrate the issue.  So I think there are
issues to deal with there.

Matt suggested looked at SQLT Parser/Producer for some
ideas about detecting the relationship types, and that
maybe it would be good to put that stuff into
DBIC::Storage.  I did look at those modules but
haven't had the length of time to familiarize myself
with it.

There's a lot to figure out here, metadata-wise. 
Maybe a good start would be to write a test that did
what we'd like, so we have something to shoot for?

I don't think right now there is going to be a lot of
traction on this issue since I know Matt is hot to get
current out.  But I'm willing/interested in
collaborating with you on this when time frees up.  We
have a lot of stuff to figure out, such as how M2M
relationship attributes should be handled, etc. 
Perhaps it might be useful to see how some of the
other ORMS handled (or mishandle) this.

--john

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Dbix-class mailing list