From: Marc Mims Date: Wed, 3 May 2006 21:07:59 +0000 (+0000) Subject: Load ::DBI::ODBC400 when a DB2/400 ODBC backend is detected. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8484b01d2b1cad8251c435177fc9b11d611fc058;p=dbsrgits%2FDBIx-Class-Historic.git Load ::DBI::ODBC400 when a DB2/400 ODBC backend is detected. --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index cee1c17..62cb900 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -421,7 +421,11 @@ sub _populate_dbh { my ($self) = @_; my @info = @{$self->_connect_info || []}; $self->_dbh($self->_connect(@info)); - my $driver = $self->_dbh->{Driver}->{Name}; + my $dbh = $self->_dbh; + my $driver = $dbh->{Driver}->{Name}; + if ( $driver eq 'ODBC' and $dbh->get_info(17) =~ m{^DB2/400} ) { + $driver = 'ODBC400'; + } eval "require DBIx::Class::Storage::DBI::${driver}"; unless ($@) { bless $self, "DBIx::Class::Storage::DBI::${driver}"; diff --git a/lib/DBIx/Class/Storage/DBI/ODBC400.pm b/lib/DBIx/Class/Storage/DBI/ODBC400.pm index 5800ab4..2167d13 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC400.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC400.pm @@ -36,14 +36,6 @@ over ODBC __PACKAGE__->load_components(qw/PK::Auto Core/); __PACKAGE__->set_primary_key('id'); - # In your Schema class - __PACKAGE__->storage_type('::DBI::ODBC400'); - -=for comment -$dbh->get_info(17) returns 'DB2/400 SQL' for an active DB2/400 connection over -ODBC. This should facility automagically loading this module when -appropriate instead of manually specifying the storage_type as shown above. - =head1 DESCRIPTION