From: Peter Rabbitson Date: Tue, 26 Oct 2010 11:51:24 +0000 (+0200) Subject: Patch up weird MRO fail on 5.8 perls X-Git-Tag: v0.08124~22 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=e8b77df681567ba57c8a12358cf9121cb8a9eeb1 Patch up weird MRO fail on 5.8 perls --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm index 4b55929..5f904d8 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm @@ -10,6 +10,9 @@ use base qw/ use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; +# Temporary fix for mysterious MRO fail on 5.8 perls +Class::C3::reinitialize if $] < '5.01'; + sub _rebless { my $self = shift; my $dbh = $self->_get_dbh; diff --git a/t/04dont_break_c3.t b/t/04dont_break_c3.t index a7de9fc..6a8496d 100644 --- a/t/04dont_break_c3.t +++ b/t/04dont_break_c3.t @@ -1,30 +1,34 @@ - +use warnings; use strict; -use Test::More tests => 2; + +use Test::More; use MRO::Compat; use lib qw(t/lib); use DBICTest; # do not remove even though it is not used { -package AAA; - -use base "DBIx::Class::Core"; + package AAA; -package BBB; + use base "DBIx::Class::Core"; +} -use base 'AAA'; +{ + package BBB; -#Injecting a direct parent. -__PACKAGE__->inject_base( __PACKAGE__, 'AAA' ); + use base 'AAA'; + #Injecting a direct parent. + __PACKAGE__->inject_base( __PACKAGE__, 'AAA' ); +} -package CCC; +{ + package CCC; -use base 'AAA'; + use base 'AAA'; -#Injecting an indirect parent. -__PACKAGE__->inject_base( __PACKAGE__, 'DBIx::Class::Core' ); + #Injecting an indirect parent. + __PACKAGE__->inject_base( __PACKAGE__, 'DBIx::Class::Core' ); } eval { mro::get_linear_isa('BBB'); }; @@ -32,3 +36,33 @@ ok (! $@, "Correctly skipped injecting a direct parent of class BBB"); eval { mro::get_linear_isa('CCC'); }; ok (! $@, "Correctly skipped injecting an indirect parent of class BBB"); + +use DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server; +use B; + +is_deeply ( + mro::get_linear_isa('DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server'), + [qw/ + DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server + DBIx::Class::Storage::DBI::Sybase + DBIx::Class::Storage::DBI::MSSQL + DBIx::Class::Storage::DBI::UniqueIdentifier + DBIx::Class::Storage::DBI + DBIx::Class::Storage::DBIHacks + DBIx::Class::Storage + DBIx::Class + DBIx::Class::Componentised + Class::C3::Componentised + Class::Accessor::Grouped + /], + 'Correctly ordered ISA of DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server' +); + +my $dialect_ref = DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server->can('sql_limit_dialect'); +is ( + B::svref_2object($dialect_ref)->GV->STASH->NAME, + 'DBIx::Class::Storage::DBI::MSSQL', + 'Correct method picked' +); + +done_testing;