X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FODBC.pm;h=1e8851b20bcd715c4a7608f9483469663f7648dc;hb=23b2c49b17262ecf84307c9ffba88ed38ecc90cb;hp=f33100c374465057fe370b510d3b70a71f36753f;hpb=2a57124dc95b1f1b8b2c2e6003a42b5777c462e4;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/ODBC.pm b/lib/DBIx/Class/Storage/DBI/ODBC.pm index f33100c..1e8851b 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC.pm @@ -1,48 +1,73 @@ package DBIx::Class::Storage::DBI::ODBC; use strict; use warnings; - use base qw/DBIx::Class::Storage::DBI/; +use mro 'c3'; -sub _rebless { - my ($self) = @_; - - my $dbh = $self->_dbh; - my $dbtype = eval { $dbh->get_info(17) }; - unless ( $@ ) { - # Translate the backend name into a perl identifier - $dbtype =~ s/\W/_/gi; - my $class = "DBIx::Class::Storage::DBI::ODBC::${dbtype}"; - eval "require $class"; - bless $self, $class unless $@; - } +use DBIx::Class::_Util 'modver_gt_or_eq'; +use namespace::clean; + +sub _rebless { shift->_determine_connector_driver('ODBC') } + +# Whether or not we are connecting via the freetds ODBC driver +sub _using_freetds { + my $self = shift; + + my $dsn = $self->_dbi_connect_info->[0]; + + return 1 if ( + ( (! ref $dsn) and $dsn =~ /driver=FreeTDS/i) + or + ( ($self->_dbh_get_info('SQL_DRIVER_NAME')||'') =~ /tdsodbc/i ) + ); + + return 0; } +# Either returns the FreeTDS version via which we are connecting, 0 if can't +# be determined, or undef otherwise +sub _using_freetds_version { + my $self = shift; + return undef unless $self->_using_freetds; + return $self->_dbh_get_info('SQL_DRIVER_VER') || 0; +} -1; +sub _disable_odbc_array_ops { + my $self = shift; + my $dbh = $self->_get_dbh; -=head1 NAME + $DBD::ODBC::__DBIC_DISABLE_ARRAY_OPS_VIA__ ||= [ do { + if( modver_gt_or_eq('DBD::ODBC', '1.35_01') ) { + odbc_array_operations => 0; + } + elsif( modver_gt_or_eq('DBD::ODBC', '1.33_01') ) { + odbc_disable_array_operations => 1; + } + }]; -DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers + if (my ($k, $v) = @$DBD::ODBC::__DBIC_DISABLE_ARRAY_OPS_VIA__) { + $dbh->{$k} = $v; + } +} -=head1 SYNOPSIS +1; - # In your table classes - __PACKAGE__->load_components(qw/Core/); +=head1 NAME +DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers =head1 DESCRIPTION This class simply provides a mechanism for discovering and loading a sub-class for a specific ODBC backend. It should be transparent to the user. +=head1 AUTHOR -=head1 AUTHORS - -Marc Mims C<< >> +See L and L. =head1 LICENSE You may distribute this code under the same terms as Perl itself. =cut +# vim:sts=2 sw=2: