don't use eval!
[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
7 sub _rebless {
8     my ($self) = @_;
9
10     my $dbtype = eval { $self->dbh->get_info(17) };
11     unless ( $@ ) {
12         # Translate the backend name into a perl identifier
13         $dbtype =~ s/\W/_/gi;
14         my $subclass = "DBIx::Class::Storage::DBI::ODBC::${dbtype}";
15         if ($self->load_optional_class($subclass) && !$self->isa($subclass)) {
16             bless $self, $subclass;
17             $self->_rebless;
18         }
19     }
20 }
21
22 sub _dbh_last_insert_id {
23     my ($self, $dbh, $source, $col) = @_;
24
25     # punt: if there is no derived class for the specific backend, attempt
26     # to use the DBI->last_insert_id, which may not be sufficient (see the
27     # discussion of last_insert_id in perldoc DBI)
28     return $dbh->last_insert_id(undef, undef, $source->from, $col);
29 }
30
31 1;
32
33 =head1 NAME
34
35 DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers
36
37 =head1 SYNOPSIS
38
39   # In your table classes
40   __PACKAGE__->load_components(qw/Core/);
41
42
43 =head1 DESCRIPTION
44
45 This class simply provides a mechanism for discovering and loading a sub-class
46 for a specific ODBC backend.  It should be transparent to the user.
47
48
49 =head1 AUTHORS
50
51 Marc Mims C<< <marc@questright.com> >>
52
53 =head1 LICENSE
54
55 You may distribute this code under the same terms as Perl itself.
56
57 =cut