All expected evals converted to try, except where no test is done,
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Oracle / Generic.pm
index c6491ab..3e74d42 100644 (file)
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Scope::Guard ();
 use Context::Preserve ();
+use Try::Tiny;
 
 =head1 NAME
 
@@ -68,8 +69,8 @@ sub _dbh_get_autoinc_seq {
   }
   else {
     $source_name = $source->name;
-    $source_name = uc($source_name) unless $sql_maker->quote_char;
   }
+  $source_name = uc($source_name) unless $sql_maker->quote_char;
 
   # trigger_body is a LONG
   local $dbh->{LongReadLen} = 64 * 1024 if ($dbh->{LongReadLen} < 64 * 1024);
@@ -95,7 +96,7 @@ sub _dbh_get_autoinc_seq {
   while (my ($insert_trigger) = $sth->fetchrow_array) {
     return $1 if $insert_trigger =~ m!("?\w+"?)\.nextval!i; # col name goes here???
   }
-  $self->throw_exception("Unable to find a sequence INSERT trigger on table '" . $source->name . "'.");
+  $self->throw_exception("Unable to find a sequence INSERT trigger on table '$source_name'.");
 }
 
 sub _sequence_fetch {
@@ -110,12 +111,16 @@ sub _ping {
   my $dbh = $self->_dbh or return 0;
 
   local $dbh->{RaiseError} = 1;
+  local $dbh->{PrintError} = 0;
 
-  eval {
-    $dbh->do("select 1 from dual");
+  my $rc = 1;
+  try {
+    $dbh->do('select 1 from dual');
+  } catch {
+    $rc = 0;
   };
 
-  return $@ ? 0 : 1;
+  return $rc;
 }
 
 sub _dbh_execute {
@@ -128,14 +133,16 @@ sub _dbh_execute {
 
   RETRY: {
     do {
-      eval {
+      my $exception;
+      try {
         if ($wantarray) {
           @res    = $self->next::method(@_);
         } else {
           $res[0] = $self->next::method(@_);
         }
+      } catch {
+        $exception = shift;
       };
-      $exception = $@;
       if ($exception =~ /ORA-01003/) {
         # ORA-01003: no statement parsed (someone changed the table somehow,
         # invalidating your cursor.)
@@ -149,7 +156,7 @@ sub _dbh_execute {
 
   $self->throw_exception($exception) if $exception;
 
-  wantarray ? @res : $res[0]
+  $wantarray ? @res : $res[0]
 }
 
 =head2 get_autoinc_seq
@@ -192,10 +199,10 @@ Used as:
 
     on_connect_call => 'datetime_setup'
 
-In L<DBIx::Class::Storage::DBI/connect_info> to set the session nls date, and
-timestamp values for use with L<DBIx::Class::InflateColumn::DateTime> and the
-necessary environment variables for L<DateTime::Format::Oracle>, which is used
-by it.
+In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set the session nls
+date, and timestamp values for use with L<DBIx::Class::InflateColumn::DateTime>
+and the necessary environment variables for L<DateTime::Format::Oracle>, which
+is used by it.
 
 Maximum allowable precision is used, unless the environment variables have
 already been set.