[CDBI] Having a column named 'id' as part of a multi-column primary key

Kingsley Kerce kingsley at kingsleysoftware.com
Thu Aug 11 17:36:48 BST 2005


Randal L. Schwartz writes:
 > >>>>> "Scotty" == Scotty Allen <lists at scottyallen.com> writes:
 > 
 > Scotty> However, this all raises a separate question: what do you do
 > Scotty> when you're retrofitting cdbi on top of an existing schema,
 > Scotty> that may have namespace collisions between columns and cdbi
 > Scotty> reserved names?  Is there a way to remap a column to a
 > Scotty> different accessor name?  Or another trick I don't know of?
 > 
 > Will the strategy under "Changing your column accessor method names"
 > on the manpage suffice?

Here is a particular example.  I have the following method in a
table's CDBI class; the table has a composite key containing "id".

sub accessor_name {
  my ($self,$column) = @_;
  return "myid" if $column eq "id";
  return $column;
}

Kings





More information about the ClassDBI mailing list