[Dbix-class] bug or misuse of $schema->register_class after upgrade ?

Bernhard Bauch bauch at zsi.at
Tue Mar 29 22:04:58 GMT 2011


dear dbix::class list,

i just tried upgrading my dbix::class from 0.08123 to the lastest 0.08127.
but some things not working right...

i am using catalyst with dbix::class.
in my App.pm after 
	__PACKAGE__->setup(); 
depending on config-files, i dynamically add some relations to some result-classes.
this worked fine with version 0.8123, but its not working as it should with the lastest version.

how i add a many2many relation after setup looks like this..

	my $myclass = $schema->class("Someclass");

	$myclass->has_many("linktable_accessor", "MyApp::Schema::Result::Linktable" , 'link_id', );
	$myclass->many_to_many("accessor", "linktable_accessor" , 'accessor', );

	$schema->unregister_source("Someclass");
	$schema->register_class("SomeClass" , $myclass);

(the results for linktable and foreignclass are well defined)

after the upgrade ... this is not working.
the hasmany accessor and many2many accessors are not available for row-items.. ("Can't locate object method ...)
if i put the two 2 statements (->has_many ... and many_to_many) in my the Result::Someclass module , dbix::class warnings appear, that some functions have already been defined. (eg. add_to_..)

asking the result for available relations with ->relationships, the "linktable_accessor" appears, but can not be accessed from a row-item.

i tried to find the difference between the 2 versions...and i figured out what part of the code is the responsible for this ..
in DBIx/Class/Schema.pm in line #925 this was added:

	weaken ${"${target_class}::__cag_result_source_instance"};

if i remove this line, everything is working like expected or like before.

what can i do to keep my code working ? any ideas ?

thanks alot for help,
bernhard






--
Bernhard Bauch, Webdevelopment
ZSI - Zentrum für soziale Innovation
bauch at zsi.at




More information about the DBIx-Class mailing list