[CDBI] Re: ChildOf

Edward J. Sabol sabol at alderaan.gsfc.nasa.gov
Sat Sep 10 01:46:03 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.

> That's not very nice from two perspectives:

> #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

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

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


P.S. Kate, you keep breaking the message threading with your responses. I
suspect you are hitting the "f" key (or similar) in your mail program
(technically, a mail user agent or MUA) because you think "f" does a
"follow-up", like in many newsreaders. But you are actually "forwarding" your
response to the mailing list. What you want is a "group reply." Forwarding
changes the Subject: header and discards the References: and In-Reply-To:
headers, which makes automatic discussion threading impossible. If your MUA
doesn't have "group reply" functionality, then please just reply and then
change the To: header to point to the mailing list. Thanks!

More information about the ClassDBI mailing list