On 9/24/07, Matt S Trout <[EMAIL PROTECTED]> wrote: > On Mon, Sep 24, 2007 at 03:11:28PM +0100, Scott Thomson wrote: > > 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 > > 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. 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 :-) > > No, that's a bug. > > I guess compose_namespace should look for classes its composing in the > inheritance tree and swap 'em for the composed version. > > Anybody up for having a go at a test+patch?
A test I can have a stab at (see attached), however I think a patch is beyond me!
XXcompose_namespace.t
Description: Troff document
_______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/ Searchable Archive: http://www.grokbase.com/group/[EMAIL PROTECTED]
