[Dbix-class] dbix + perl5.18

Bernhard Bauch bauch at zsi.at
Wed Jun 12 14:34:00 GMT 2013


On 12.06.2013, at 16:17, Peter Rabbitson wrote:

> On Wed, Jun 12, 2013 at 03:42:20PM +0200, Bernhard Bauch wrote:
>> dear dbix-folks,
>> 
>> ...
>> 
>> 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 ....
>> 
> 
> This can't be true - _map_namespaces returns a list, without any
> kind of order (it's Filesystem order). Even if it did - the order
> would not be preserved on older perls either, after the hash
> assignment.

oh sorry-  i "mis-read" the code -- i thought _map_namespace provides an ordred list of modules (the order in which the modules need to be loaded)

the order of the list (returned by $class->_map_namespaces(@$result_namespace) ) is always "the same" (not changing on reload/restart/compile)
and my class load/run fine with that.


but this :
	my %res	ults = $class->_map_namespaces(@$result_namespace);
	for my $res (values %results) {
		print "class: $res";
	}
shows a different order every time...
	


> 
>> 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) {
>> ---------------------------
> 
> 
> This can't be the correct fix due to reasons described above. Something 
> else is happening that prevents a *specific class* requiring its 
> far-relationship side.
> 
> Please provide several definitions of the adected classes (both the ones 
> that throw an exception, and the ones whose load fails).



this is the "ordered" class list returned by $class->_map_namespaces(@$result_namespace);

----------------------------
loading: Newindigo::Schema::Result::Attachment
loading: Newindigo::Schema::Result::Startpage
loading: Newindigo::Schema::Result::Settings
loading: Newindigo::Schema::Result::Object
loading: Newindigo::Schema::Result::Zone
loading: Newindigo::Schema::Result::Users
loading: Newindigo::Schema::Result::UsersRole
loading: Newindigo::Schema::Result::Page
loading: Newindigo::Schema::Result::Country
loading: Newindigo::Schema::Result::Stakeholder
loading: Newindigo::Schema::Result::Role
loading: Newindigo::Schema::Result::StakeholderUsers
loading: Newindigo::Schema::Result::ZoneObject
loading: Newindigo::Schema::Result::AttachmentBase
loading: Newindigo::Schema::Result::Tag
loading: Newindigo::Schema::Result::TagObject
loading: Newindigo::Schema::Result::ProjectStakeholder
loading: Newindigo::Schema::Result::Object::Project
----------------------------


my Packages + inhertiance (for Newindigo::Schema::Result::Object::Project) look like this .....
(all other class above inherit from Newindigo::Schema::Result)....


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

package Newindigo::Schema::Result::Object::Project;

use utf8;
use Moose;
use MooseX::NonMoose;
use MooseX::MarkAsMethods autoclean => 1;

extends 'Newindigo::Schema::Result::Object';
....


--------------------------------
package Newindigo::Schema::Result::Object;

use Moose;
use namespace::autoclean;

extends 'Newindigo::Schema::Result';
.....


--------------------------------
package Newindigo::Schema::Result;

use Moose;
use namespace::autoclean;

extends 'CatalystX::SEAC::Schema::Result';
.....



--------------------------------
package CatalystX::SEAC::Schema::Result;

use Moose;
use MooseX::NonMoose;
use namespace::autoclean;

extends 'DBIx::Class::Core';
.....


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


need/want more infos ?

thanks,
bye, bernhard




> 
>> 
>> maybe this should be fixed in upcoming DBIx::Class releases ?
> 
> It should definitely be fixed, but first the real problem must be 
> identified ;)
> 
> Cheers
> 
> 
> _______________________________________________
> 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 at zsi.at
Skype: berni-zsi




More information about the DBIx-Class mailing list