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