[Dbix-class] Inheritance not preserved when using compose_namespace

Scott Thomson smoothhound at gmail.com
Mon Sep 24 15:11:28 GMT 2007

Hi All,

I posted a version of this problem on the catalyst list but I now
think it's more DBIC related so excuse the cross-post :-)

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 I use the dynamic sub-classing
approach in the 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 value of 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

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

It seems that the B isa A relationship is not preserved within the
MyApp::Model namespace.  After some digging around 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 would affect any schema that is
generated using the compose_namespace method.

I'm a bit stumped on how to proceed, I can get round the problem with
a bit of a hack (basically by not using the relationship to set
values) but I'm converting a large set of classes to DBIC and this
problem is going to occur in quite a few places.

Given the ubiquity of DBIC as a model for Catalyst I'm quite surprised
that no-one has come up against this before - which may mean that it's
something that I'm doing wrong  :-)



More information about the DBIx-Class mailing list