Better diagnostics in the case of missing drivers, slight ADO/ODBC refactor
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC.pm
CommitLineData
2a57124d 1package DBIx::Class::Storage::DBI::ODBC;
2use strict;
3use warnings;
2a57124d 4use base qw/DBIx::Class::Storage::DBI/;
2ad62d97 5use mro 'c3';
2a57124d 6
75d3bdb2 7sub _rebless { shift->_determine_connector_driver('ODBC') }
52b420dd 8
75d3bdb2 9# Whether or not we are connecting via the freetds ODBC driver
aca3b4c3 10sub _using_freetds {
11 my $self = shift;
12
13 my $dsn = $self->_dbi_connect_info->[0];
14
15 return 1 if (
16 ( (! ref $dsn) and $dsn =~ /driver=FreeTDS/i)
17 or
18 ( ($self->_dbh_get_info('SQL_DRIVER_NAME')||'') =~ /tdsodbc/i )
19 );
20
21 return 0;
22}
23
24# Either returns the FreeTDS version via which we are connecting, 0 if can't
25# be determined, or undef otherwise
26sub _using_freetds_version {
27 my $self = shift;
28 return undef unless $self->_using_freetds;
29 return $self->_dbh_get_info('SQL_DRIVER_VER') || 0;
30}
31
11f7049f 32sub _disable_odbc_array_ops {
33 my $self = shift;
34 my $dbh = $self->_get_dbh;
35
36 if (eval { DBD::ODBC->VERSION('1.35_01') }) {
37 $dbh->{odbc_array_operations} = 0;
38 }
39 elsif (eval { DBD::ODBC->VERSION('1.33_01') }) {
40 $dbh->{odbc_disable_array_operations} = 1;
41 }
42}
43
2a57124d 441;
45
46=head1 NAME
47
48DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers
49
2a57124d 50=head1 DESCRIPTION
51
52This class simply provides a mechanism for discovering and loading a sub-class
53for a specific ODBC backend. It should be transparent to the user.
54
ab17c175 55=head1 AUTHOR
2a57124d 56
ab17c175 57See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
2a57124d 58
59=head1 LICENSE
60
61You may distribute this code under the same terms as Perl itself.
62
63=cut
ab17c175 64# vim:sts=2 sw=2: