Now I just need to check if the actual values are set...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC / Microsoft_SQL_Server.pm
index ff79f54..4383e4d 100644 (file)
@@ -6,7 +6,30 @@ use base qw/DBIx::Class::Storage::DBI::MSSQL/;
 
 sub insert_bulk {
   my ($self, $source, $cols, $data) = @_;
+
+  my $identity_insert = 0;
+
+  COLUMNS:
+  foreach my $col (@{$cols}) {
+    if ($source->column_info($col)->{is_auto_increment}) {
+      $identity_insert = 1;
+      last COLUMNS;
+    }
+  }
+
+  my $table = $source->from;
+  $source->storage->dbh_do(sub {
+      my ($storage, $dbh, @cols) = @_;
+      $dbh->do("SET IDENTITY_INSERT $table ON;");
+    });
+
   next::method(@_);
+
+  $source->storage->dbh_do(sub {
+      my ($storage, $dbh, @cols) = @_;
+      $dbh->do("SET IDENTITY_INSERT $table OFF;");
+    });
+
 }
 
 sub _prep_for_execute {