fix a bug in _determine_driver
Rafael Kitover [Fri, 31 Jul 2009 13:52:41 +0000 (13:52 +0000)]
lib/DBIx/Class/Storage/DBI.pm
t/74mssql.t

index f975986..946678c 100644 (file)
@@ -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);
index 55d599f..a3c2cc0 100644 (file)
@@ -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;