[CDBI] Re: has_a relationship with non-primary column?
Edward J. Sabol
sabol at alderaan.gsfc.nasa.gov
Fri Sep 7 18:04:30 BST 2007
Praveen Hombaiah <phombaiah at gmail.com> 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()?
More information about the ClassDBI