factor out subclass-specific _execute_array callback
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase.pm
index f73f634..b6352e0 100644 (file)
@@ -277,7 +277,8 @@ sub _prep_for_execute {
     );
   }
 
-  if ($op eq 'insert' && (not $bound_identity_col) && $identity_col) {
+  if ($op eq 'insert' && (not $bound_identity_col) && $identity_col &&
+      (not $self->{insert_bulk})) {
     $sql =
       "$sql\n" .
       $self->_fetch_identity_sql($ident, $identity_col);
@@ -512,8 +513,12 @@ EOF
       && (not $is_identity_insert)
       && ($self->_identity_method||'') ne '@@IDENTITY';
 
-    $self     = $self->_writer_storage;
-    my $guard = $self->txn_scope_guard;
+    ($self, my $guard) = $self->{transaction_depth} == 0 ? 
+      ($self->_writer_storage, $self->_writer_storage->txn_scope_guard)
+      :
+      ($self, undef);
+
+    local $self->{insert_bulk} = 1;
 
     $self->next::method(@_);
 
@@ -541,7 +546,8 @@ EOF
       }
     }
 
-    $guard->commit;
+    $guard->commit if $guard;
+
     return;
   }
 
@@ -658,8 +664,14 @@ EOF
   }
 }
 
-# Sybase is very sensitive to this.
-sub _exhaust_statements { 1 }
+sub _dbh_execute_array {
+  my ($self, $sth, $tuple_status, $cb) = @_;
+
+  my $rv = $self->next::method($sth, $tuple_status);
+  $cb->() if $cb;
+
+  return $rv;
+}
 
 # Make sure blobs are not bound as placeholders, and return any non-empty ones
 # as a hash.