#644 ✓not-applicable
crantz

Relationship objects only work one way

Reported by crantz | November 6th, 2008 @ 09:28 PM

In the old days, relationship objects worked both ways, i.e. you could call both get_children and get_parent on one. Both methods still exist, but only one of them can be used on a given relationship object.

Example: http://pastie.org/230755

There are probably not many situations in which this causes a big problem, but it feels a bit unclean imho, and it does limit the usefulness of the relationship objects.

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 2nd, 2008 @ 04:52 AM

    • Assigned user cleared.
    • State changed from “new” to “open”

    This will likely be resolved in dkubb/dm-core. The goal is that for each 2-way relationship a single Relationship object will be able to describe it.

    You will be able to call a method when given the parent to retrieve all the children, as well as a method when given the child to retrieve the parent. There will also be introspection methods to find out the parent/child models, the parent/child keys, the accessor/mutator method names on both sides, and the query defaults that are used.

    The rest of the API is still unclear, but the goal is to have something much cleaner than what is currently in sam/dm-core.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 2nd, 2008 @ 04:52 AM

    • Assigned user set to “Dan Kubb (dkubb)”
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 4th, 2008 @ 03:47 AM

    • State changed from “open” to “accepted”

    I am accepting this and leave it in LH because while it is a suggestion it's also a pretty large flaw in the design of the Relationship object. Fixing it will also solve a whole host of issues with the associations code, so I am eager to work on this in the dkubb/dm-core branch.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 4th, 2009 @ 02:59 AM

    This has been resolved in dkubb/dm-core, the new API is much cleaner. However, it was decided against dual-direction relationships.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 4th, 2009 @ 02:59 AM

    • State changed from “accepted” to “not-applicable”

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages