DBIC Inheritance not preserved in Catalyst model

View: New views
2 Messages — Rating Filter:   Alert me  

DBIC Inheritance not preserved in Catalyst model

by Scott Thomson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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::DBIC::A::B=HASH(0x392b6a0) isn't a MyAPP::Model::DBIC::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.


_______________________________________________
List: Catalyst@...
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

Re: DBIC Inheritance not preserved in Catalyst model

by Scott Thomson-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've done a bit more digging around and it seems like it is the call to compose_namespace in Catalyst::Model::DBIC::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 <smoothhound@...> 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::DBIC::A::B=HASH(0x392b6a0) isn't a MyAPP::Model::DBIC::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.



_______________________________________________
List: Catalyst@...
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/