Re: pk as fk IsA can't bind reference

[prev] [thread] [next] [Date index for 2005/03/25]

From: Rhesa Rozendaal
Subject: Re: pk as fk IsA can't bind reference
Date: 18:01 on 25 Mar 2005
jldommer@xxxx.xxxxx.xxx wrote:
> Hi all,
> 
> TestOracle::Artist->create( {
>   alias => 'First',
>   firstname => 'Jane',
>   surname => 'Doe'
>  }
> );
> 
> The CPAN documentation seems to suggest that this should work.  The parent is created without incident, but when cdbi tries to generate the child I get an error that says

Yes, that should work.

> package TestOracle::Artist;
> use base qw(TestOracle::ClassDBI);
> 
> TestOracle::Artist->table('artist')|| die "Table connection not made: $DBI::errstr";
> TestOracle::Artist->columns(Primary   => qw/artistid/);
> TestOracle::Artist->columns(Others    => qw/alias/);
> 
> TestOracle::Artist->is_a( 'artistid' => 'TestOracle::Person' );

This doesn't seem right: you map the pk of Artist to the pk of Person. I think you need to add a person column to this table that functions 
as the fk for the relationship.
The general advice to not inflate your primary key into an object seems to be relevant here.

	TestOracle::Artist->columns(Others    => qw/alias person/);
  	TestOracle::Artist->is_a( 'person' => 'TestOracle::Person' );

To me this makes sense, actually, because in reality there are other types of persons possible: you could have a Manager type Person. And 
some persons might have multiple roles as well.

HTH,
Rhesa
	

pk as fk IsA can't bind reference
jldommer 17:19 on 25 Mar 2005

Re: pk as fk IsA can't bind reference
Rhesa Rozendaal 18:01 on 25 Mar 2005

Generated at 14:42 on 11 Apr 2005 by mariachi v0.52