fix and regression test for RT #62642
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC.pm
1 package DBIx::Class::Storage::DBI::ODBC;
2 use strict;
3 use warnings;
4
5 use base qw/DBIx::Class::Storage::DBI/;
6 use mro 'c3';
7 use Try::Tiny;
8 use namespace::clean;
9
10 sub _rebless {
11   my ($self) = @_;
12
13   try {
14     my $dbtype = $self->_get_dbh->get_info(17);
15
16     # Translate the backend name into a perl identifier
17     $dbtype =~ s/\W/_/gi;
18     my $subclass = "DBIx::Class::Storage::DBI::ODBC::${dbtype}";
19
20     if ($self->load_optional_class($subclass) && !$self->isa($subclass)) {
21       bless $self, $subclass;
22       $self->_rebless;
23     }
24   };
25 }
26
27 1;
28
29 =head1 NAME
30
31 DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers
32
33 =head1 DESCRIPTION
34
35 This class simply provides a mechanism for discovering and loading a sub-class
36 for a specific ODBC backend.  It should be transparent to the user.
37
38 =head1 AUTHORS
39
40 Marc Mims C<< <marc@questright.com> >>
41
42 =head1 LICENSE
43
44 You may distribute this code under the same terms as Perl itself.
45
46 =cut