check DBD::ODBC version when disabling array ops
Rafael Kitover [Sat, 31 Mar 2012 15:01:22 +0000 (11:01 -0400)]
After 1.35 DBD::ODBC will disable array operations for execute_for_fetch
by default, and the $dbh attribute is changing from
'odbc_disable_array_operations' to 'odbc_array_operations', but we still
set the new attribute to 0 just in case.

Put the version checks and the setting of the appropriate attribute in
_disable_odbc_array_ops in ODBC.pm, and call it from the 3 drivers where
we currently need to disable them.

lib/DBIx/Class/Storage/DBI/ODBC.pm
lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm
lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm
lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm

index 65bc811..d9852e7 100644 (file)
@@ -51,6 +51,18 @@ sub _using_freetds_version {
   return $self->_dbh_get_info('SQL_DRIVER_VER') || 0;
 }
 
+sub _disable_odbc_array_ops {
+  my $self = shift;
+  my $dbh  = $self->_get_dbh;
+
+  if (eval { DBD::ODBC->VERSION('1.35_01') }) {
+    $dbh->{odbc_array_operations} = 0;
+  }
+  elsif (eval { DBD::ODBC->VERSION('1.33_01') }) {
+    $dbh->{odbc_disable_array_operations} = 1;
+  }
+}
+
 1;
 
 =head1 NAME
index f2bbb64..3a630cc 100644 (file)
@@ -66,7 +66,7 @@ sub _run_connection_actions {
   }
 
   # batch operations do not work
-  $self->_get_dbh->{odbc_disable_array_operations} = 1;
+  $self->_disable_odbc_array_ops;
 
   return $self->next::method(@_);
 }
index 9741a45..ac0afbb 100644 (file)
@@ -38,7 +38,7 @@ sub _run_connection_actions {
   my $self = shift;
 
   if ($self->_dbh_get_info('SQL_DRIVER_NAME') eq 'OdbcFb') {
-    $self->_get_dbh->{odbc_disable_array_operations} = 1;
+    $self->_disable_odbc_array_ops;
   }
 
   return $self->next::method(@_);
index 1b5fba2..7f8339a 100644 (file)
@@ -265,7 +265,7 @@ sub _run_connection_actions {
 
     # FreeTDS is too broken wrt execute_for_fetch batching
     # just disable it outright until things quiet down
-    $self->_get_dbh->{odbc_disable_array_operations} = 1;
+    $self->_disable_odbc_array_ops;
   }
 }