[CDBI] Re: has_a relationship with non-primary column?

"Edward J. Sabol" <sabol-2oVx0MVsMgiP/[email protected]> Fri, 7 Sep 2007 13:04:30 -0400
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
Praveen Hombaiah <[email protected]> asked:
>> Isn't the first argument the column(of this class ie department ) that
>> stores the value of the PK of the "other" class?  Is it possible to store
>> the non-pk value of the "other" class in the column and indicate that in the
>> has_a declaration somehow?

Perrin Harkins replied:
> Oh, now I see what you're asking.  You can't do that with has_a, but
> making your own accessor is pretty simple:

If I'm correctly understanding what the original poster is asking, then I've
run into this more often than I would like as well. might_have() can sort of
do this, right? It sets up an accessor to a non-PK column in a related table.
I don't know about anyone else, but I've often wished that has_a() could do
that as well or that there was a third-party CDBI::Relationship with HasA.pm
semantics that would facilitate this. Depending on your circumstances,
perhaps one could just use might_have() instead of has_a()?

Later,
Ed