after doing a try-run of bringing all modules (catalyst, dbix::class, ...) up-to-date, i ran into some problems.
i found a solution for the problem, but there are still some open questions.
i am creating some "onthefly" relations at after catalyst setup is completed.
(see full-details below this mail).
the resultset class was accessed via:
my $myclass = $schema->class("Someclass");
$myclass is "MyApp::Model::DB::Someclass" now.creating a many2many relation on $myclass did not work as it should with latest dbix::class.
the solution was to access the class via "MyApp::Schema::Result::Someclass"
so the question is:
why is using $schema->class("...") ending in a different behavior that using the bare result class name ?
or am i doing things terribly wrong ?
thanks for tipps and helps,
bernhard
Begin forwarded message:
From: Bernhard Bauch <bauch@zsi.at>
Date: 30. M?rz 2011 00:04:58 MESZ
To: dbix-class@lists.scsys.co.uk
Subject: [Dbix-class] bug or misuse of $schema->register_class after upgrade ?
Reply-To: "DBIx::Class user and developer list" <dbix-class@lists.scsys.co.uk>
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@zsi.at
_______________________________________________
List: http://lists.scsys.co.uk/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/dbix-class@lists.scsys.co.uk
--Date: 30. M?rz 2011 00:04:58 MESZ
To: dbix-class@lists.scsys.co.uk
Subject: [Dbix-class] bug or misuse of $schema->register_class after upgrade ?
Reply-To: "DBIx::Class user and developer list" <dbix-class@lists.scsys.co.uk>
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@zsi.at
_______________________________________________
List: http://lists.scsys.co.uk/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/dbix-class@lists.scsys.co.uk
Bernhard Bauch, Webdevelopment
ZSI - Zentrum f?r soziale Innovation
bauch@zsi.at