[Bast-commits] r6650 - DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI/ODBC

frew at dev.catalyst.perl.org frew at dev.catalyst.perl.org
Fri Jun 12 15:26:53 GMT 2009


Author: frew
Date: 2009-06-12 15:26:53 +0000 (Fri, 12 Jun 2009)
New Revision: 6650

Modified:
   DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
Log:
Insert Identity works!

Modified: DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm	2009-06-12 15:13:32 UTC (rev 6649)
+++ DBIx-Class/0.08/branches/mssql_top_fixes/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm	2009-06-12 15:26:53 UTC (rev 6650)
@@ -12,23 +12,28 @@
   COLUMNS:
   foreach my $col (@{$cols}) {
     if ($source->column_info($col)->{is_auto_increment}) {
+      warn $col;
       $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;");
-    });
+  if ($identity_insert) {
+    $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;");
-    });
+  if ($identity_insert) {
+    $source->storage->dbh_do(sub {
+	my ($storage, $dbh, @cols) = @_;
+	$dbh->do("SET IDENTITY_INSERT $table OFF;");
+      });
+  }
 
 }
 




More information about the Bast-commits mailing list