X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FADO.pm;h=8c647359ec9e61ab2d566a951d307a3c6f1b114e;hb=696ba760d112264ea22e8b20db55987746677b81;hp=91d731c3770dae3bfede4a9efbf8233df9ea8159;hpb=56dca25f0e1582928ba897df4e1cf44c9710d4f2;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/ADO.pm b/lib/DBIx/Class/Storage/DBI/ADO.pm index 91d731c..8c64735 100644 --- a/lib/DBIx/Class/Storage/DBI/ADO.pm +++ b/lib/DBIx/Class/Storage/DBI/ADO.pm @@ -2,7 +2,8 @@ package DBIx::Class::Storage::DBI::ADO; use base 'DBIx::Class::Storage::DBI'; use mro 'c3'; -use Try::Tiny; + +use Sub::Name; use namespace::clean; =head1 NAME @@ -23,16 +24,24 @@ sub _rebless { my $dbtype = $self->_dbh_get_info(17); if (not $dbtype) { - warn 'Unable to determine ADO driver, failling back to generic support'; + warn "Unable to determine ADO driver, failling back to generic support.\n"; return; } $dbtype =~ s/\W/_/gi; + my $subclass = "DBIx::Class::Storage::DBI::ADO::${dbtype}"; - if ($self->load_optional_class($subclass) && !$self->isa($subclass)) { + + return if $self->isa($subclass); + + if ($self->load_optional_class($subclass)) { bless $self, $subclass; $self->_rebless; } + else { + warn "Expected driver '$subclass' not found, using generic support. " . + "Please file an RT.\n"; + } } # cleanup some warnings from DBD::ADO @@ -50,6 +59,27 @@ sub _dbh_get_info { $self->next::method(@_); } +# Monkeypatch out the horrible warnings during global destruction. +# A patch to DBD::ADO has been submitted as well. +# https://rt.cpan.org/Ticket/Display.html?id=65563 +sub _init { + no warnings 'redefine'; + require DBD::ADO; + + if ($DBD::ADO::VERSION <= 2.98) { + my $disconnect = *DBD::ADO::db::disconnect{CODE}; + + *DBD::ADO::db::disconnect = subname 'DBD::ADO::db::disconnect' => sub { + my $warn_handler = $SIG{__WARN__} || sub { warn @_ }; + local $SIG{__WARN__} = sub { + $warn_handler->(@_) + unless $_[0] =~ /Not a Win32::OLE object|uninitialized value/; + }; + $disconnect->(@_); + }; + } +} + # Here I was just experimenting with ADO cursor types, left in as a comment in # case you want to as well. See the DBD::ADO docs. #sub _dbh_sth {