X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FADO.pm;h=c7c0621fd0f793ba17198789319669291add8378;hb=514b84f6b60b566d75d2ff2ddd08659c4cf7b427;hp=8cca22d0f8670201f80a66c1cbff896b62c08a1d;hpb=af1f4f842ae446a3339b92b33851ea80c928f17a;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/ADO.pm b/lib/DBIx/Class/Storage/DBI/ADO.pm index 8cca22d..c7c0621 100644 --- a/lib/DBIx/Class/Storage/DBI/ADO.pm +++ b/lib/DBIx/Class/Storage/DBI/ADO.pm @@ -1,10 +1,12 @@ 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 DBIx::Class::_Util qw( sigwarn_silencer modver_gt_or_eq set_subname ); use namespace::clean; =head1 NAME @@ -19,43 +21,16 @@ should be transparent to the user. =cut -sub _rebless { - my $self = shift; - - my $dbtype = $self->_dbh_get_info('SQL_DBMS_NAME'); - - 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 sub _dbh_get_info { my $self = shift; - my $warn_handler = $SIG{__WARN__} || sub { warn @_ }; - - local $SIG{__WARN__} = sub { - $warn_handler->(@_) - unless $_[0] =~ m{^Missing argument in sprintf at \S+/ADO/GetInfo\.pm}; - }; + local $SIG{__WARN__} = sigwarn_silencer( + qr{^Missing argument in sprintf at \S+/ADO/GetInfo\.pm} + ); $self->next::method(@_); } @@ -68,16 +43,14 @@ sub _init { unless ($DBD::ADO::__DBIC_MONKEYPATCH_CHECKED__) { require DBD::ADO; - unless (try { DBD::ADO->VERSION('2.99'); 1 }) { + unless ( modver_gt_or_eq( 'DBD::ADO', '2.99' ) ) { 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/; - }; + *DBD::ADO::db::disconnect = set_subname 'DBD::ADO::db::disconnect' => sub { + local $SIG{__WARN__} = sigwarn_silencer( + qr/Not a Win32::OLE object|uninitialized value/ + ); $disconnect->(@_); }; } @@ -88,7 +61,7 @@ sub _init { # 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 @@ -100,15 +73,19 @@ sub _init { # $sth; #} -1; +=head1 FURTHER QUESTIONS? -=head1 AUTHOR +Check the list of L. -See L and L. +=head1 COPYRIGHT AND LICENSE -=head1 LICENSE - -You may distribute this code under the same terms as Perl itself. +This module is free software L +by the L. You can +redistribute it and/or modify it under the same terms as the +L. =cut + +1; + # vim:sts=2 sw=2: