From: Rafael Kitover Date: Fri, 30 Mar 2012 17:51:43 +0000 (-0400) Subject: fix mro issues under 5.8 X-Git-Tag: 0.07020~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=383bd2a81c777be9a2f0f66195dbdf24d3b97a86;p=dbsrgits%2FDBIx-Class-Schema-Loader.git fix mro issues under 5.8 Add a Class::C3::reinitialize() under 5.8 after the ::DBI ->_rebless. Also make sure MRO::Compat is loaded everywhere it needs to be and everything does a use mro 'c3';. --- diff --git a/Changes b/Changes index 4fdbd20..1cace5f 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - fix some mro issues under perl 5.8 + 0.07019 2012-03-28 17:23:09 - fix some errors due to case issues (RT#75805) diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index bba84e3..5e0382a 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -3,6 +3,7 @@ package DBIx::Class::Schema::Loader::Base; use strict; use warnings; use base qw/Class::Accessor::Grouped Class::C3::Componentised/; +use MRO::Compat; use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; use DBIx::Class::Schema::Loader::RelBuilder (); diff --git a/lib/DBIx/Class/Schema/Loader/DBI.pm b/lib/DBIx/Class/Schema/Loader/DBI.pm index 131b3d3..56251e2 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI.pm @@ -54,9 +54,10 @@ sub new { my $driver = $self->dbh->{Driver}->{Name}; my $subclass = 'DBIx::Class::Schema::Loader::DBI::' . $driver; - if ($self->load_optional_class($subclass)) { - bless $self, $subclass unless $self->isa($subclass); + if ((not $self->isa($subclass)) && $self->load_optional_class($subclass)) { + bless $self, $subclass; $self->_rebless; + Class::C3::reinitialize() if $] < 5.009005; } } @@ -66,7 +67,7 @@ sub new { $self->_setup; - $self; + return $self; } sub _build_quote_char { diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Component/QuotedDefault.pm b/lib/DBIx/Class/Schema/Loader/DBI/Component/QuotedDefault.pm index cf97f70..abe19d7 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Component/QuotedDefault.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Component/QuotedDefault.pm @@ -2,6 +2,7 @@ package DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault; use strict; use warnings; +use base 'DBIx::Class::Schema::Loader::DBI'; use mro 'c3'; our $VERSION = '0.07019'; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/InterBase.pm b/lib/DBIx/Class/Schema/Loader/DBI/InterBase.pm index 4c934af..46e447d 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/InterBase.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/InterBase.pm @@ -2,8 +2,8 @@ package DBIx::Class::Schema::Loader::DBI::InterBase; use strict; use warnings; -use mro 'c3'; use base qw/DBIx::Class::Schema::Loader::DBI/; +use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; use List::Util 'first'; use namespace::clean; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/ODBC/ACCESS.pm b/lib/DBIx/Class/Schema/Loader/DBI/ODBC/ACCESS.pm index 274dece..d2659a3 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/ODBC/ACCESS.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/ODBC/ACCESS.pm @@ -2,9 +2,7 @@ package DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS; use strict; use warnings; -use base qw/ - DBIx::Class::Schema::Loader::DBI::ODBC -/; +use base 'DBIx::Class::Schema::Loader::DBI::ODBC'; use mro 'c3'; use Try::Tiny; use namespace::clean; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm b/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm index c09da67..2c5153b 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm @@ -2,10 +2,7 @@ package DBIx::Class::Schema::Loader::DBI::Oracle; use strict; use warnings; -use base qw/ - DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault - DBIx::Class::Schema::Loader::DBI -/; +use base 'DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault'; use mro 'c3'; use Try::Tiny; use namespace::clean; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index 0745bd9..b779159 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -2,10 +2,7 @@ package DBIx::Class::Schema::Loader::DBI::Pg; use strict; use warnings; -use base qw/ - DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault - DBIx::Class::Schema::Loader::DBI -/; +use base 'DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault'; use mro 'c3'; our $VERSION = '0.07019'; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm index 5428500..1bcaec2 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLAnywhere.pm @@ -2,10 +2,7 @@ package DBIx::Class::Schema::Loader::DBI::SQLAnywhere; use strict; use warnings; -use base qw/ - DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault - DBIx::Class::Schema::Loader::DBI -/; +use base 'DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault'; use mro 'c3'; use List::MoreUtils 'any'; use namespace::clean; diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm index 7154a1c..74c6224 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm @@ -2,10 +2,7 @@ package DBIx::Class::Schema::Loader::DBI::SQLite; use strict; use warnings; -use base qw/ - DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault - DBIx::Class::Schema::Loader::DBI -/; +use base 'DBIx::Class::Schema::Loader::DBI::Component::QuotedDefault'; use mro 'c3'; use DBIx::Class::Schema::Loader::Table (); diff --git a/lib/DBIx/Class/Schema/Loader/DBObject.pm b/lib/DBIx/Class/Schema/Loader/DBObject.pm index 7a7b53c..afa116c 100644 --- a/lib/DBIx/Class/Schema/Loader/DBObject.pm +++ b/lib/DBIx/Class/Schema/Loader/DBObject.pm @@ -3,6 +3,7 @@ package DBIx::Class::Schema::Loader::DBObject; use strict; use warnings; use base 'Class::Accessor::Grouped'; +use mro 'c3'; use Carp::Clan qw/^DBIx::Class/; use Scalar::Util 'weaken'; use namespace::clean; diff --git a/lib/DBIx/Class/Schema/Loader/DBObject/Informix.pm b/lib/DBIx/Class/Schema/Loader/DBObject/Informix.pm index 9636fb0..bf9e1f1 100644 --- a/lib/DBIx/Class/Schema/Loader/DBObject/Informix.pm +++ b/lib/DBIx/Class/Schema/Loader/DBObject/Informix.pm @@ -3,6 +3,7 @@ package DBIx::Class::Schema::Loader::DBObject::Informix; use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBObject'; +use mro 'c3'; use namespace::clean; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/DBObject/Sybase.pm b/lib/DBIx/Class/Schema/Loader/DBObject/Sybase.pm index 4e2bb47..a39b9ee 100644 --- a/lib/DBIx/Class/Schema/Loader/DBObject/Sybase.pm +++ b/lib/DBIx/Class/Schema/Loader/DBObject/Sybase.pm @@ -3,6 +3,7 @@ package DBIx::Class::Schema::Loader::DBObject::Sybase; use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBObject'; +use mro 'c3'; use namespace::clean; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/Table.pm b/lib/DBIx/Class/Schema/Loader/Table.pm index 4f470dc..a9feb15 100644 --- a/lib/DBIx/Class/Schema/Loader/Table.pm +++ b/lib/DBIx/Class/Schema/Loader/Table.pm @@ -3,6 +3,7 @@ package DBIx::Class::Schema::Loader::Table; use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBObject'; +use mro 'c3'; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/Table/Informix.pm b/lib/DBIx/Class/Schema/Loader/Table/Informix.pm index 1b0fe63..b7e974f 100644 --- a/lib/DBIx/Class/Schema/Loader/Table/Informix.pm +++ b/lib/DBIx/Class/Schema/Loader/Table/Informix.pm @@ -3,6 +3,7 @@ package DBIx::Class::Schema::Loader::Table::Informix; use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBObject::Informix'; +use mro 'c3'; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/Table/Sybase.pm b/lib/DBIx/Class/Schema/Loader/Table/Sybase.pm index 2f900c3..e94b7ed 100644 --- a/lib/DBIx/Class/Schema/Loader/Table/Sybase.pm +++ b/lib/DBIx/Class/Schema/Loader/Table/Sybase.pm @@ -3,6 +3,7 @@ package DBIx::Class::Schema::Loader::Table::Sybase; use strict; use warnings; use base 'DBIx::Class::Schema::Loader::DBObject::Sybase'; +use mro 'c3'; =head1 NAME diff --git a/t/90bug_58_mro.t b/t/90bug_58_mro.t new file mode 100644 index 0000000..53556e0 --- /dev/null +++ b/t/90bug_58_mro.t @@ -0,0 +1,39 @@ +use strict; +use warnings; +use Test::More; +use Test::Exception; +use DBIx::Class::Schema::Loader; + +# use this if you keep a copy of DBD::Sybase linked to FreeTDS somewhere else +BEGIN { + if (my $lib_dirs = $ENV{DBICTEST_MSSQL_PERL5LIB}) { + unshift @INC, $_ for split /:/, $lib_dirs; + } +} + +my ($dsn, $user, $pass); + +for (qw/MSSQL_ODBC MSSQL_ADO MSSQL/) { + next unless $ENV{"DBICTEST_${_}_DSN"}; + + $dsn = $ENV{"DBICTEST_${_}_DSN"}; + $user = $ENV{"DBICTEST_${_}_USER"}; + $pass = $ENV{"DBICTEST_${_}_PASS"}; + + last; +} + +plan skip_all => 'perl 5.8 required for this test' + if $] >= 5.009005; + +plan ($dsn ? (tests => 1) : (skip_all => 'MSSQL required for this test')); + +lives_ok { + DBIx::Class::Schema::Loader::make_schema_at( + 'DBICTest::Schema', + { naming => 'current' }, + [ $dsn, $user, $pass ], + ); +} 'dynamic MSSQL schema created using make_schema_at'; + +done_testing;