X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FODBC.pm;h=d9852e7c692a3f180f3fb1ba219d3fc1959e804e;hb=11f7049f71cd5d6b891e8addd3c0d9cd2a27c3e8;hp=7a20900eaaf9edff53947490fabadb54cb5f3aee;hpb=fd323bf1046faa7de5a8c985268d80ec5b703361;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/ODBC.pm b/lib/DBIx/Class/Storage/DBI/ODBC.pm index 7a20900..d9852e7 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC.pm @@ -1,27 +1,66 @@ package DBIx::Class::Storage::DBI::ODBC; use strict; use warnings; - use base qw/DBIx::Class::Storage::DBI/; use mro 'c3'; -use Try::Tiny; -use namespace::clean; sub _rebless { my ($self) = @_; - try { - my $dbtype = $self->_get_dbh->get_info(17); - + if (my $dbtype = $self->_dbh_get_info('SQL_DBMS_NAME')) { # Translate the backend name into a perl identifier $dbtype =~ s/\W/_/gi; my $subclass = "DBIx::Class::Storage::DBI::ODBC::${dbtype}"; - if ($self->load_optional_class($subclass) && !$self->isa($subclass)) { + return if $self->isa($subclass); + + if ($self->load_optional_class($subclass)) { bless $self, $subclass; $self->_rebless; } - }; + else { + warn "Expected driver '$subclass' not found, using generic support. " . + "Please file an RT.\n"; + } + } + else { + warn "Could not determine your database type, using generic support.\n"; + } +} + +# 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; +} + +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; @@ -35,12 +74,13 @@ DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers 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 AUTHORS +=head1 AUTHOR -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: