[CDBI] RE: ChildOf

Kate Yoak kate at yoak.com
Sat Sep 10 02:30:46 BST 2005


> > Good point. Forgot to explain. The problem with has_a is that it takes
> > your primary column, your object id (that you are probably using
> > everywhere in urls, keys, etc) and turns it into a parent object.
>
> Huh? No, it doesn't. It will take the child's foreign key column
> and turn it
> into a parent object. Is that what you meant? Has_a doesn't do anything to
> the primary key unless you specifiy a has_a on the primary key, and that's
> explicitly discouraged in the CDBI documentation and leads to
> broken behavior.

Yes, that is exactly what I meant.  Sorry for the confusion.

> > #1. I like my id where it is! :-) I mean, really - when I say <a
> > href="/?a_id=<%$link->link_id%>"> I expect a number to show up. (I
> > believe it actually will - because of stringify - but read on).
>
> Most people using CDBI really don't fiddle with stringification.
> It's almost
> never a good idea. Personally, I would just use $link instead of
> $link->link_id.

Hey - that's actually way cool!  Haven't thought of that.
>
> > #2. I don't want to go to the database for the parent just because I am
> > accessing the child's id.
>
> OK, that's valid. There is some overhead here, but CDBI goes to
> the database
> for a lot of things that you wouldn't think it would go to the
> database for.
> I suspect it's barely another drop in the bucket.
>

have to agree with you here.

> It sounds like ChildOf is just HasAWithSpecifiedAccessorName,
> which certainly
> could be useful. I'd almost suggest that you add the accessor
> name capability
> to HasA instead of proliferating a new Relationship, but you'd have to go
> through Tony for that and he may or may not be receptive to such an
> enhancement.
>

It does start to sound like it...  I am in general against having hundreds
of modules and would much prefer slowly integrating them together - it's
difficult enough to figure out what you are supposed to be using and why as
it is.  Not to mention what works and what's still broken.  Moreover, as I
am starting to work with this new relationship, i find that other modules
(like Sweet) already do certain things for exising relationships (like
prefetch) and I am out of luck.

May be I'll try to email tony after a while.  These are not well-formed
enough thoughts to propose much. But I am glad I posted them here.  I think
after I am done with my current project I might post various other things I
found useful to see if they should be stuck somewhere in existing cpan code.

P.S.  I apologize for breaking threads.  I will try to find a solution that
does a better job soon.






More information about the ClassDBI mailing list