Switch to C3 mro throughout the ::Storage hierarchy (DBIx::Class brings in MRO::Compa...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC.pm
CommitLineData
2a57124d 1package DBIx::Class::Storage::DBI::ODBC;
2use strict;
3use warnings;
4
5use base qw/DBIx::Class::Storage::DBI/;
2ad62d97 6use mro 'c3';
2a57124d 7
8sub _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 23sub _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
321;
33
34=head1 NAME
35
36DBIx::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
46This class simply provides a mechanism for discovering and loading a sub-class
47for a specific ODBC backend. It should be transparent to the user.
48
49
50=head1 AUTHORS
51
c1e64353 52Marc Mims C<< <marc@questright.com> >>
2a57124d 53
54=head1 LICENSE
55
56You may distribute this code under the same terms as Perl itself.
57
58=cut