[CDBI] Worknig on Class::DBI::Relationship::IsA

Rhesa Rozendaal perl at rhesa.com
Thu Feb 23 23:13:14 GMT 2006


Hi Peter!

Glad to see you're working on IsA :)

Before this trail goes cold, I'll quickly give you my thoughts.

> 1) How to Handle  CDBI Frozen vs Not Frozen versions.  I am thinking
> that *EVEN* versions numbers on IsA will be compatible with the CDBI
> Frozen and Odd numbers with later releases.   ?  Is this a good or bad
> idea? Any better ideas?

I would prefer not having to think about which version I should install. On 
top of that, I would _love_ IsA to play nice with Class::DBI::Sweet.
An even/odd scheme doesn't sound practical to me, not least because the CPAN 
shell will generally give you the latest version.

> 2) One to One vs Many to One.  -- from my DB  knowledge  I understand
> IsA rels to be of either 1:1 or M:1 relationship types.  I want to
> make IsA cascade delete if it is a 1:1.  I'm thinking of doing that by
> passing an extra arg to the isa call:
> 
> Music::Artist->is_a(person => 'Music::Person', {one_to_one     => 1} );
> Music::Person->is_a(species => 'HomoSapien', {many_to_one => 1} ); # fancy has_a
> 
> Any objections to this interface? Better ideas?

Can't tell. I only use 1-1, pretty much like might_have. I'd probably like it 
to default to 1-1.

> 3) Are the docs still wrong on usage ? I find that I have to declare
> which column to "import" from the IsA class in my classes column
> lists. This may be a good thing as you have some control over methods
> created for you. The docs say :
> 
>   Music::Artist->columns(All => qw/artistid alias/);
>   Music::Artist->is_a(person => 'Music::Person'); # Music::Artist
> inherits Person accessors

This definitely works for me exactly like it says here, using (the older) 0.05.

> But my experience is this:
> 
>   Music::Artist->columns(All => qw/artistid alias first_name  last_name dob/);
> 
>   Music::Artist->is_a(person => 'Music::Person'); # Music::Artist only
> inherits Person first_name,
>                                                             #
> last_name, and dob

No, I have not had this experience at all. Mind you, I've never used the 0.05 
that's on CPAN at the moment, because it had several issues. The version 
before that (also 0.05) works pretty well though, and doesn't exhibit what you 
describe here.

> An official test will take care of what is and is not.  I would like to know --
> What is desired?  Personally I am leaning toward being abel to declare
> which are inherited.  It could be an arg that defaults to all.

I think having control is nice, see the way might_have works. I would be fine 
with having them all imported by default.

>  Also, maybe the issue is that the accessor is created but it does not
> get put in the "All" colums list and it is causing me problems.
> Music::Artist->is_a(person => 'Music::Person', { inherit =>
> [first_name, ...] });
> 
> Thoughts?

That looks good. Personally, I don't see a problem with those accessors not 
being in All. They're not columns of this object, so the accessors should just 
proxy on to the parent object, in my view.


One thing that was lacking from the 0.05 I'm using was that has_many relations 
of the parent class were not (properly?) imported into the child. Has_a 
relations on the other hand _are_ imported. I would enjoy having the 
has_many's as well :)

The second thing I'd like to see is the removal of the hard-coded reference to 
'Class::DBI::search', so that IsA can be made to work with CDBI::Sweet. See my 
recent post to this list for more details.

Other than these two items, I've been fairly satisfied with IsA sofar: it 
works for what I need from it.

I'm willing to help in testing your new versions. Just let me know what I can do.

Rhesa




More information about the ClassDBI mailing list