Unbreak devrel version checks
[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
b1dbf716 7use DBIx::Class::_Util 'modver_gt_or_eq';
8use namespace::clean;
9
75d3bdb2 10sub _rebless { shift->_determine_connector_driver('ODBC') }
52b420dd 11
75d3bdb2 12# Whether or not we are connecting via the freetds ODBC driver
aca3b4c3 13sub _using_freetds {
14 my $self = shift;
15
16 my $dsn = $self->_dbi_connect_info->[0];
17
18 return 1 if (
19 ( (! ref $dsn) and $dsn =~ /driver=FreeTDS/i)
20 or
21 ( ($self->_dbh_get_info('SQL_DRIVER_NAME')||'') =~ /tdsodbc/i )
22 );
23
24 return 0;
25}
26
27# Either returns the FreeTDS version via which we are connecting, 0 if can't
28# be determined, or undef otherwise
29sub _using_freetds_version {
30 my $self = shift;
31 return undef unless $self->_using_freetds;
32 return $self->_dbh_get_info('SQL_DRIVER_VER') || 0;
33}
34
11f7049f 35sub _disable_odbc_array_ops {
36 my $self = shift;
37 my $dbh = $self->_get_dbh;
38
b1dbf716 39 $DBD::ODBC::__DBIC_DISABLE_ARRAY_OPS_VIA__ ||= [ do {
40 if( modver_gt_or_eq('DBD::ODBC', '1.35_01') ) {
41 odbc_array_operations => 0;
42 }
43 elsif( modver_gt_or_eq('DBD::ODBC', '1.33_01') ) {
44 odbc_disable_array_operations => 1;
45 }
46 }];
47
48 if (my ($k, $v) = @$DBD::ODBC::__DBIC_DISABLE_ARRAY_OPS_VIA__) {
49 $dbh->{$k} = $v;
11f7049f 50 }
51}
52
2a57124d 531;
54
55=head1 NAME
56
57DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers
58
2a57124d 59=head1 DESCRIPTION
60
61This class simply provides a mechanism for discovering and loading a sub-class
62for a specific ODBC backend. It should be transparent to the user.
63
ab17c175 64=head1 AUTHOR
2a57124d 65
ab17c175 66See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
2a57124d 67
68=head1 LICENSE
69
70You may distribute this code under the same terms as Perl itself.
71
72=cut
ab17c175 73# vim:sts=2 sw=2: