CDR::IsA and relationships in the parent class

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

From: Rhesa Rozendaal
Subject: CDR::IsA and relationships in the parent class
Date: 18:07 on 19 Mar 2005
Hi,

I've started implementing a new database model, and it seems I'm running into a limitation of Class::DBI::Relationship::IsA. It works 
perfectly for accessing columns in the parent class, but it seems the relationships defined in the parent class are not mapped to the child 
class.
I'd like to know if it's possible to get those mappings implemented in CDR::IsA, and if so, can anyone give me some pointers on how to get 
started on it?

Let me describe briefly what I mean, by extending the canonical model:

  package Music::Person;
  Music::Person->table('person');
  Music::Person->columns(All => qw/personid firstname initials surname date_of_birth/);

  Music::Person->has_many(addresses => 'Address'); ### <<<--- not inherited by Artist

  package Music::Artist;
  Music::Artist->table('artist');
  Music::Artist->columns(All => qw/artistid alias/);
  Music::Artist->has_many(cds => 'Music::CD');
  Music::Artist->is_a(personid => 'Music::Person'); # Music::Artist inherits accessors from Music::Person

The artist class now has access to all the column in Person, i.e.

  $artist->surname

accesses the column in the person table. That's cool.
What I can not say, however, is this:

  $artist->add_to_addresses({ street => '1 Ave.', zip => '12345' });

Instead, I need to access the parent object first, and call the address methods on that:

  $artist->person->add_to_addresses({ street => '1 Ave.', zip => '12345' });

Of course, this gets tedious very quickly, especially if the parent class has many more relationships, and when there are several classes 
that are_a Music::Person (Music::Consumer for instance).

I'd be more than willing to implement it myself (especially seeing how busy Aaron is from his last message), but I'd like to have some 
guidance on how to proceed.

Thanks!
Rhesa Rozendaal

CDR::IsA and relationships in the parent class
Rhesa Rozendaal 18:07 on 19 Mar 2005

Generated at 11:29 on 21 Mar 2005 by mariachi v0.52