X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FADO.pm;h=705a59852a39ef5b61e9194ba12eec691a4b7956;hb=b1dbf7164ee06fa23aef5a799dd57df0357514ba;hp=36423c4e14a2361f131ffc7d0565b48b9a3908d4;hpb=55f68788a1e0975e4cc36e0623bf4b70c514b46e;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/ADO.pm b/lib/DBIx/Class/Storage/DBI/ADO.pm index 36423c4..705a598 100644 --- a/lib/DBIx/Class/Storage/DBI/ADO.pm +++ b/lib/DBIx/Class/Storage/DBI/ADO.pm @@ -1,9 +1,13 @@ package DBIx::Class::Storage::DBI::ADO; +use warnings; +use strict; + use base 'DBIx::Class::Storage::DBI'; use mro 'c3'; use Sub::Name; +use Try::Tiny; use namespace::clean; =head1 NAME @@ -18,31 +22,7 @@ should be transparent to the user. =cut -sub _rebless { - my $self = shift; - - my $dbtype = $self->_dbh_get_info(17); - - if (not $dbtype) { - 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}"; - - 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"; - } -} +sub _rebless { shift->_determine_connector_driver('ADO') } # cleanup some warnings from DBD::ADO # RT#65563, not fixed as of DBD::ADO v2.98 @@ -60,29 +40,34 @@ sub _dbh_get_info { } # Monkeypatch out the horrible warnings during global destruction. -# A patch to DBD::ADO has been submitted as well. +# A patch to DBD::ADO has been submitted as well, and it was fixed +# as of 2.99 # 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/; + unless ($DBD::ADO::__DBIC_MONKEYPATCH_CHECKED__) { + require DBD::ADO; + + unless (try { DBD::ADO->VERSION('2.99'); 1 }) { + no warnings 'redefine'; + 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->(@_); }; - $disconnect->(@_); - }; + } + + $DBD::ADO::__DBIC_MONKEYPATCH_CHECKED__ = 1; } } # 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 { +#sub _prepare_sth { # my ($self, $dbh, $sql) = @_; # # my $sth = $self->disable_sth_caching