The cursor class is now autoloaded due to CAG component_class acc. group
[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
7sub _rebless {
52b420dd 8 my ($self) = @_;
9
af1f4f84 10 if (my $dbtype = $self->_dbh_get_info('SQL_DBMS_NAME')) {
52b420dd 11 # Translate the backend name into a perl identifier
12 $dbtype =~ s/\W/_/gi;
13 my $subclass = "DBIx::Class::Storage::DBI::ODBC::${dbtype}";
14
726c8f65 15 return if $self->isa($subclass);
16
17 if ($self->load_optional_class($subclass)) {
52b420dd 18 bless $self, $subclass;
19 $self->_rebless;
2a57124d 20 }
ab17c175 21 else {
22 warn "Expected driver '$subclass' not found, using generic support. " .
23 "Please file an RT.\n";
24 }
25 }
26 else {
27 warn "Could not determine your database type, using generic support.\n";
4888397f 28 }
2a57124d 29}
30
aca3b4c3 31# Whether or not we are connecting via the freetds ODBC driver.
32sub _using_freetds {
33 my $self = shift;
34
35 my $dsn = $self->_dbi_connect_info->[0];
36
37 return 1 if (
38 ( (! ref $dsn) and $dsn =~ /driver=FreeTDS/i)
39 or
40 ( ($self->_dbh_get_info('SQL_DRIVER_NAME')||'') =~ /tdsodbc/i )
41 );
42
43 return 0;
44}
45
46# Either returns the FreeTDS version via which we are connecting, 0 if can't
47# be determined, or undef otherwise
48sub _using_freetds_version {
49 my $self = shift;
50 return undef unless $self->_using_freetds;
51 return $self->_dbh_get_info('SQL_DRIVER_VER') || 0;
52}
53
2a57124d 541;
55
56=head1 NAME
57
58DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers
59
2a57124d 60=head1 DESCRIPTION
61
62This class simply provides a mechanism for discovering and loading a sub-class
63for a specific ODBC backend. It should be transparent to the user.
64
ab17c175 65=head1 AUTHOR
2a57124d 66
ab17c175 67See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
2a57124d 68
69=head1 LICENSE
70
71You may distribute this code under the same terms as Perl itself.
72
73=cut
ab17c175 74# vim:sts=2 sw=2: