List Info

Thread: DBIC Inheritance not preserved in Catalyst model




DBIC Inheritance not preserved in Catalyst model
user name
2007-09-21 08:24:33
I have a setup similar to this...

Class B inherits from class A and class C has a relationship to A.
A and B share the same table and use the dynamic sub-classing approach in the DBIC cookbook to get the sub-classing to work.

When testing directly with the schema the classes behave as I would expect, ie. I can set the relationship on C using an object of class either A or B. However, when I use the schema inside my Catalyst app I get an error like this when trying to set the property using the relationship on A to an object of the sub-class C...

DBIx::Class::MyApp::new(): Object MyApp::Model:BIC::A::B=HASH(0x392b6a0) isn't a MyAPP::Model:BIC::A (The error is generated in DBIx::Class::Relationship::Base::set_from_related)

It seems that the B isa A relationship is not preserved within the MyApp::Model namespace.

The model works correctly in all other ways (so far).

Any ideas on how to get round this are extremely welcome    I can post real code if required.

Cheers,

Scott.

Re: DBIC Inheritance not preserved in Catalyst model
user name
2007-09-24 08:57:05
I've done a bit more digging around and it seems like it is the call to compose_namespace in Catalyst::Model:BIC::Schema::new that is causing this behaviour.  Effectively it renames all the schema classes into the MyApp::Model namespace and the ISA chain in the new namespace is not preserved.

So this is probably more of a DBIC problem, in that any schema that is generated using compose_namespace will be affected, so I reckon I should post on their list.

Cheers,

Scott

On 9/21/07, Scott Thomson < smoothhoundgmail.com">smoothhoundgmail.com> wrote:
I have a setup similar to this...

Class B inherits from class A and class C has a relationship to A.
A and B share the same table and use the dynamic sub-classing approach in the DBIC cookbook to get the sub-classing to work.

When testing directly with the schema the classes behave as I would expect, ie. I can set the relationship on C using an object of class either A or B. However, when I use the schema inside my Catalyst app I get an error like this when trying to set the property using the relationship on A to an object of the sub-class C...

DBIx::Class::MyApp::new(): Object MyApp::Model:BIC::A::B=HASH(0x392b6a0) isn't a MyAPP::Model:BIC::A (The error is generated in DBIx::Class::Relationship::Base::set_from_related)

It seems that the B isa A relationship is not preserved within the MyApp::Model namespace.

The model works correctly in all other ways (so far).

Any ideas on how to get round this are extremely welcome&nbsp;   I can post real code if required.

Cheers,

Scott.


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )