[Bast-commits] r6919 - in DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage: . DBI/Oracle DBI/Sybase

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Wed Jul 1 15:39:19 GMT 2009


Author: caelum
Date: 2009-07-01 15:39:18 +0000 (Wed, 01 Jul 2009)
New Revision: 6919

Modified:
   DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
   DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm
Log:
move connection tests into _ping()

Modified: DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
===================================================================
--- DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm	2009-07-01 15:20:52 UTC (rev 6918)
+++ DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm	2009-07-01 15:39:18 UTC (rev 6919)
@@ -83,33 +83,18 @@
   return $id;
 }
 
-=head2 connected
-
-Returns true if we have an open (and working) database connection, false if it is not (yet)
-open (or does not work). (Executes a simple SELECT to make sure it works.)
-
-The reason this is needed is that L<DBD::Oracle>'s ping() does not do a real
-OCIPing but just gets the server version, which doesn't help if someone killed
-your session.
-
-=cut
-
-sub connected {
+sub _ping {
   my $self = shift;
 
-  if (not $self->next::method(@_)) {
-    return 0;
-  } else {
-    my $dbh = $self->_dbh;
+  my $dbh = $self->_dbh or return 0;
 
-    local $dbh->{RaiseError} = 1;
+  local $dbh->{RaiseError} = 1;
 
-    eval {
-      $dbh->do("select 1 from dual");
-    };
+  eval {
+    $dbh->do("select 1 from dual");
+  };
 
-    return $@ ? 0 : 1;
-  }
+  return $@ ? 0 : 1;
 }
 
 sub _dbh_execute {

Modified: DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm
===================================================================
--- DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm	2009-07-01 15:20:52 UTC (rev 6918)
+++ DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm	2009-07-01 15:39:18 UTC (rev 6919)
@@ -1,4 +1,5 @@
-package DBIx::Class::Storage::DBI::Sybase::Base;
+package # hide from PAUSE
+    DBIx::Class::Storage::DBI::Sybase::Base;
 
 use strict;
 use warnings;
@@ -8,24 +9,12 @@
 DBIx::Class::Storage::DBI::Sybase::Base - Common functionality for drivers using
 DBD::Sybase
 
-=head1 METHODS
-
-=head2 connected
-
-Returns true if we have an open (and working) database connection, false if it
-is not (yet) open (or does not work). (Executes a simple SELECT to make sure it
-works.)
-
-The reason this is needed is that L<DBD::Sybase>'s ping() does not work with an
-active statement handle, leading to masked database errors.
-
 =cut
 
-sub connected {
+sub _ping {
   my $self = shift;
 
   my $dbh = $self->_dbh or return 0;
-  $dbh->FETCH('Active') or return 0;
 
   local $dbh->{RaiseError} = 1;
   eval {

Modified: DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI.pm	2009-07-01 15:20:52 UTC (rev 6918)
+++ DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI.pm	2009-07-01 15:39:18 UTC (rev 6919)
@@ -669,12 +669,20 @@
           $self->_verify_pid;
           return 0 if !$self->_dbh;
       }
-      return ($dbh->FETCH('Active') && $dbh->ping);
+      return ($dbh->FETCH('Active') && $self->_ping);
   }
 
   return 0;
 }
 
+sub _ping {
+  my $self = shift;
+
+  my $dbh = $self->_dbh or return 0;
+
+  return $dbh->ping;
+}
+
 # handle pid changes correctly
 #  NOTE: assumes $self->_dbh is a valid $dbh
 sub _verify_pid {




More information about the Bast-commits mailing list