release 0.07008
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / DBI / ODBC.pm
1 package DBIx::Class::Schema::Loader::DBI::ODBC;
2
3 use strict;
4 use warnings;
5 use base 'DBIx::Class::Schema::Loader::DBI';
6 use mro 'c3';
7 use Carp::Clan qw/^DBIx::Class/;
8 use namespace::clean;
9
10 our $VERSION = '0.07008';
11
12 =head1 NAME
13
14 DBIx::Class::Schema::Loader::DBI::ODBC - L<DBD::ODBC> proxy
15
16 =head1 DESCRIPTION
17
18 Reblesses into an C<::ODBC::> class when connecting via L<DBD::ODBC>.
19
20 Code stolen from the L<DBIx::Class> ODBC storage.
21
22 See L<DBIx::Class::Schema::Loader::Base> for usage information.
23
24 =cut
25
26 sub _rebless {
27   my $self = shift;
28
29   return if ref $self ne __PACKAGE__;
30
31 # stolen from DBIC ODBC storage
32   my $dbh  = $self->schema->storage->dbh;
33   my $dbtype = eval { $dbh->get_info(17) };
34   unless ( $@ ) {
35     # Translate the backend name into a perl identifier
36     $dbtype =~ s/\W/_/gi;
37     my $class = "DBIx::Class::Schema::Loader::DBI::ODBC::${dbtype}";
38     if ($self->load_optional_class($class) && !$self->isa($class)) {
39         bless $self, $class;
40         $self->_rebless;
41     }
42   }
43 }
44
45 sub _tables_list {
46     my ($self, $opts) = @_;
47
48     return $self->next::method($opts, undef, undef);
49 }
50
51 =head1 SEE ALSO
52
53 L<DBIx::Class::Schema::Loader::DBI::ODBC::Microsoft_SQL_Server>,
54 L<DBIx::Class::Schema::Loader::DBI::ODBC::SQL_Anywhere>,
55 L<DBIx::Class::Schema::Loader::DBI::ODBC::Firebird>,
56 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
57 L<DBIx::Class::Schema::Loader::DBI>
58
59 =head1 AUTHOR
60
61 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
62
63 =head1 LICENSE
64
65 This library is free software; you can redistribute it and/or modify it under
66 the same terms as Perl itself.
67
68 =cut
69
70 1;