From: Rafael Kitover Date: Fri, 31 Jul 2009 13:52:41 +0000 (+0000) Subject: fix a bug in _determine_driver X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c29ce31779a99ead1195746f213889162bee17cb;p=dbsrgits%2FDBIx-Class-Historic.git fix a bug in _determine_driver --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index f975986..946678c 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -764,21 +764,23 @@ sub _determine_driver { my ($self) = @_; if (not $self->_driver_determined) { - my $driver; - - if ($self->_dbh) { # we are connected - $driver = $self->_dbh->{Driver}{Name}; - } else { - # try to use dsn to not require being connected, the driver may still - # force a connection in _rebless to determine version - ($driver) = $self->_dbi_connect_info->[0] =~ /dbi:([^:]+):/i; - } + if (ref($self) eq __PACKAGE__) { + my $driver; + + if ($self->_dbh) { # we are connected + $driver = $self->_dbh->{Driver}{Name}; + } else { + # try to use dsn to not require being connected, the driver may still + # force a connection in _rebless to determine version + ($driver) = $self->_dbi_connect_info->[0] =~ /dbi:([^:]+):/i; + } - my $storage_class = "DBIx::Class::Storage::DBI::${driver}"; - if ($self->load_optional_class($storage_class)) { - mro::set_mro($storage_class, 'c3'); - bless $self, $storage_class; - $self->_rebless(); + my $storage_class = "DBIx::Class::Storage::DBI::${driver}"; + if ($self->load_optional_class($storage_class)) { + mro::set_mro($storage_class, 'c3'); + bless $self, $storage_class; + $self->_rebless(); + } } $self->_driver_determined(1); diff --git a/t/74mssql.t b/t/74mssql.t index 55d599f..a3c2cc0 100644 --- a/t/74mssql.t +++ b/t/74mssql.t @@ -23,8 +23,8 @@ my $TESTS = 13; plan tests => $TESTS * 2; my @storage_types = ( - 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server', - 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars', + 'DBI::Sybase::Microsoft_SQL_Server', + 'DBI::Sybase::Microsoft_SQL_Server::NoBindVars', ); my $storage_idx = -1; my $schema; @@ -35,7 +35,7 @@ for my $storage_type (@storage_types) { $schema = DBICTest::Schema->clone; if ($storage_idx != 0) { # autodetect - $schema->storage_type($storage_type); + $schema->storage_type("::$storage_type"); } $schema->connection($dsn, $user, $pass); @@ -48,7 +48,7 @@ for my $storage_type (@storage_types) { next; } - isa_ok($schema->storage, $storage_type); + isa_ok($schema->storage, "DBIx::Class::Storage::$storage_type"); # start disconnected to test reconnection $schema->storage->_dbh->disconnect;