From: Rafael Kitover Date: Sat, 31 Mar 2012 15:01:22 +0000 (-0400) Subject: check DBD::ODBC version when disabling array ops X-Git-Tag: v0.08197~56 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=11f7049f71cd5d6b891e8addd3c0d9cd2a27c3e8;p=dbsrgits%2FDBIx-Class.git check DBD::ODBC version when disabling array ops 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. --- diff --git a/lib/DBIx/Class/Storage/DBI/ODBC.pm b/lib/DBIx/Class/Storage/DBI/ODBC.pm index 65bc811..d9852e7 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC.pm @@ -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 diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm b/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm index f2bbb64..3a630cc 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm @@ -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(@_); } diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm index 9741a45..ac0afbb 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Firebird.pm @@ -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(@_); diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm index 1b5fba2..7f8339a 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm @@ -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; } }