better connection test
Rafael Kitover [Wed, 1 Jul 2009 13:35:07 +0000 (13:35 +0000)]
lib/DBIx/Class/Storage/DBI/Sybase/Base.pm
t/746sybase.t
t/74mssql.t

index a26ed23..d4e287e 100644 (file)
@@ -24,11 +24,12 @@ active statement handle, leading to masked database errors.
 sub connected {
   my $self = shift;
 
-  my $dbh = $self->_dbh;
+  my $super = eval { $self->next::method(@_) };
 
-  local $dbh->{RaiseError} = 1;
+  return $super unless $@;
 
-  my $ping_sth;
+  my $dbh = $self->_dbh;
+  local $dbh->{RaiseError} = 1;
 
   eval {
     my $ping_sth = $dbh->prepare_cached("select 1");
index 10378cf..2d42130 100644 (file)
@@ -16,7 +16,7 @@ my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {AutoCommit => 1});
 
 # start disconnected to test reconnection
 $schema->storage->ensure_connected;
-$schema->storage->disconnect;
+$schema->storage->_dbh->disconnect;
 
 isa_ok( $schema->storage, 'DBIx::Class::Storage::DBI::Sybase' );
 
index 7de09ef..7b4ddd3 100644 (file)
@@ -24,7 +24,7 @@ $schema->connection($dsn, $user, $pass);
 
 # start disconnected to test reconnection
 $schema->storage->ensure_connected;
-$schema->storage->disconnect;
+$schema->storage->_dbh->disconnect;
 
 my $dbh = $schema->storage->dbh;