From: Rafael Kitover Date: Wed, 1 Jul 2009 13:35:07 +0000 (+0000) Subject: better connection test X-Git-Tag: v0.08108~35^2~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=526dc858fec4cfc63c8bc2de69c972fc6cbcccec;p=dbsrgits%2FDBIx-Class.git better connection test --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm index a26ed23..d4e287e 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm @@ -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"); diff --git a/t/746sybase.t b/t/746sybase.t index 10378cf..2d42130 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -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' ); diff --git a/t/74mssql.t b/t/74mssql.t index 7de09ef..7b4ddd3 100644 --- a/t/74mssql.t +++ b/t/74mssql.t @@ -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;