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