[Dbix-class] dbix + perl5.18

Bernhard Bauch bauch at zsi.at
Wed Jun 12 13:42:20 GMT 2013


dear dbix-folks,

i just upgraded to the latest perl 5.18....
and from that time i got problems with loading my dbix:class Schema....

errors for example look like this (only one at a time ..randomly):

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

{UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: DBIx::Class::Relationship::BelongsTo::belongs_to(): Can't infer join condition for 'zone' on MyApp::Schema::Result::ZoneObject: Can't locate object method "_pri_cols" via package "MyApp::Schema::Result::Zone" at .....perl5/DBIx/Class/Relationship/BelongsTo.pm line 29. at .../Schema/Result/ZoneObject.pm line 22

{UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: DBIx::Class::Relationship::BelongsTo::belongs_to(): Can't infer join condition for 'project' on MyApp::Schema::Result::ProjectStakeholder: Can't locate object method "_pri_cols" via package "MyApp::Schema::Result::Object::Project" at ...../lib/perl5/DBIx/Class/Relationship/BelongsTo.pm line 29. at /....../Schema/Result/ProjectStakeholder.pm line 20

{UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: {UNKNOWN}: Can't locate object method "load_components" via package "MyApp::Schema::Result::Object::Project" at ...../Schema/Result/Object/Project.pm line 11.

{UNKNOWN}: {UNKNOWN}: {UNKNOWN}: DBIx::Class::Relationship::BelongsTo::belongs_to(): Can't infer join condition for 'stakeholder' on MyApp::Schema::Result::StakeholderUsers: Can't locate object method "_pri_cols" via package "MyApp::Schema::Result::Stakeholder" at ..../lib/perl5/DBIx/Class/Relationship/BelongsTo.pm line 29. at ...../Schema/Result/StakeholderUsers.pm line 21

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

the funny thing is, that sometimes it loads fine ... sometimes one of the erros occure.

i figured out where the problem is!

since perl 5.18 >>> hash-ramdomizatiomn is used see:
	https://metacpan.org/module/RJBS/perl-5.18.0/pod/perldelta.pod#Hash-randomization

in DBIx::Class::Schema.pm line 232: 
	my %results = $class->_map_namespaces(@$result_namespace);
an ordered list of result classes is stored in an hash ....

later in line242:
    for my $res (values %results) {
	$class->ensure_class_loaded($res);
this hash is used
the error ist, that "values" return a randomly sorted list now ... the correct order coming from
	$class->_map_namespaces(@$result_namespace);
is neglected.


this was my workaround-fix ....
---------------------------
diff Schema.pm_fix Schema.pm
235,241d234
<     # correct order !!!
<     my @result_classes;
<     foreach my $class ( $class->_map_namespaces(@$result_namespace) ){
<         push (@result_classes, $class) if $class =~ /Schema::Result/;
<     }
< 
< 
249,250c242
< #    for my $res (values %results) {
<     for my $res ( @result_classes )  {
---
>     for my $res (values %results) {
---------------------------

maybe this should be fixed in upcoming DBIx::Class releases ?

cheers,
berni




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




More information about the DBIx-Class mailing list