FAQ
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.

Search Discussions

  • John Napiorkowski at May 25, 2007 at 6:59 pm

    --- Zbigniew Lukasiak 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
  • Matt S Trout at May 26, 2007 at 1:21 am

    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.
    Last time you asked about this I spent some time with you working out an
    API for this.

    Where are you up to with the patches to implement it?

    --
    Matt S Trout Need help with your Catalyst or DBIx::Class project?
    Technical Director Want a managed development or deployment platform?
    Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
    http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
  • Zbigniew Lukasiak at May 29, 2007 at 3:22 pm

    Last time you asked about this I spent some time with you working out an
    API for this.
    What I remember is that you proposed I should come with something that
    would play nicely with Moose. At that point I've started to read
    about Moose and think what you meant with that - and by now I have
    following thoughts on that:

    1. What Moose would change is that we shall have a way to list all the
    methods of a given Row object, but we shall not know where those
    methods come from (i.e. if it is a field method or a relationship).
    But still this would work on the Row object on on the ResultSource so
    I don't know how relevant is that. I am not sure if I understand
    Moose enough - so correct me if I am wrong.

    2. Before Moose we need a method to list all the many_to_many
    relationships - so I would propose a ->m2m_relationships method on a
    ResultSource (resembling the ->relationships method)

    3. We need also a way to check some metadata about the many_to_many
    relationships - I would propose a ->m2m_relationship_info (similar to
    ->relationship_info).

    I am still not sure what did mean this 'play nicely with Moose' -
    Moose seems pretty general and I don't see how something could be
    incompatible with it, and if Moose would duplicate some code than we
    could just make it obsolete.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdbix-class @
categoriesperl, catalyst
postedMay 25, '07 at 11:11a
activeMay 29, '07 at 3:22p
posts4
users3
websitedbix-class.org
irc#dbix-class

People

Translate

site design / logo © 2021 Grokbase