unfuck ensure_connected for odbc/mssql
Rafael Kitover [Tue, 14 Jul 2009 22:14:09 +0000 (22:14 +0000)]
lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm

index 028d9d6..0a58c76 100644 (file)
@@ -77,8 +77,9 @@ sub connect_call_use_dynamic_cursors {
   if (not exists $dbi_attrs->{odbc_cursortype}) {
     # turn on support for multiple concurrent statements, unless overridden
     $self->_dbi_connect_info->[-1] = { %$dbi_attrs, odbc_cursortype => 2 };
-    # will take effect next connection
+    my $connected = defined $self->_dbh;
     $self->disconnect;
+    $self->ensure_connected if $connected;
     $self->_using_dynamic_cursors(1);
   }
 }
@@ -138,8 +139,9 @@ sub connect_call_use_mars {
 
   if ($dsn !~ /MARS_Connection=/) {
     $self->_dbi_connect_info->[0] = "$dsn;MARS_Connection=Yes";
-    # will take effect next connection
+    my $connected = defined $self->_dbh;
     $self->disconnect;
+    $self->ensure_connected if $connected;
   }
 }