Add strict/warnings test, adjust all offenders (wow, that was a lot)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ADO.pm
CommitLineData
56dca25f 1package DBIx::Class::Storage::DBI::ADO;
4ffa5700 2
4a233f30 3use warnings;
4use strict;
5
4ffa5700 6use base 'DBIx::Class::Storage::DBI';
56dca25f 7use mro 'c3';
4ffa5700 8
772a1a25 9use Sub::Name;
8892d8e5 10use Try::Tiny;
772a1a25 11use namespace::clean;
12
56dca25f 13=head1 NAME
14
15DBIx::Class::Storage::DBI::ADO - Support for L<DBD::ADO>
16
17=head1 DESCRIPTION
18
19This class provides a mechanism for discovering and loading a sub-class
20for a specific ADO backend, as well as some workarounds for L<DBD::ADO>. It
21should be transparent to the user.
22
23=cut
24
75d3bdb2 25sub _rebless { shift->_determine_connector_driver('ADO') }
56dca25f 26
27# cleanup some warnings from DBD::ADO
28# RT#65563, not fixed as of DBD::ADO v2.98
29sub _dbh_get_info {
30 my $self = shift;
31
32 my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
33
34 local $SIG{__WARN__} = sub {
35 $warn_handler->(@_)
36 unless $_[0] =~ m{^Missing argument in sprintf at \S+/ADO/GetInfo\.pm};
52b420dd 37 };
56dca25f 38
39 $self->next::method(@_);
4ffa5700 40}
41
772a1a25 42# Monkeypatch out the horrible warnings during global destruction.
8892d8e5 43# A patch to DBD::ADO has been submitted as well, and it was fixed
44# as of 2.99
772a1a25 45# https://rt.cpan.org/Ticket/Display.html?id=65563
46sub _init {
8892d8e5 47 unless ($DBD::ADO::__DBIC_MONKEYPATCH_CHECKED__) {
48 require DBD::ADO;
49
50 unless (try { DBD::ADO->VERSION('2.99'); 1 }) {
51 no warnings 'redefine';
52 my $disconnect = *DBD::ADO::db::disconnect{CODE};
53
54 *DBD::ADO::db::disconnect = subname 'DBD::ADO::db::disconnect' => sub {
55 my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
56 local $SIG{__WARN__} = sub {
57 $warn_handler->(@_)
58 unless $_[0] =~ /Not a Win32::OLE object|uninitialized value/;
59 };
60 $disconnect->(@_);
772a1a25 61 };
8892d8e5 62 }
63
64 $DBD::ADO::__DBIC_MONKEYPATCH_CHECKED__ = 1;
772a1a25 65 }
66}
67
748eb620 68# Here I was just experimenting with ADO cursor types, left in as a comment in
69# case you want to as well. See the DBD::ADO docs.
4ffa5700 70#sub _dbh_sth {
71# my ($self, $dbh, $sql) = @_;
72#
73# my $sth = $self->disable_sth_caching
74# ? $dbh->prepare($sql, { CursorType => 'adOpenStatic' })
75# : $dbh->prepare_cached($sql, { CursorType => 'adOpenStatic' }, 3);
76#
77# $self->throw_exception($dbh->errstr) if !$sth;
78#
79# $sth;
80#}
81
821;
56dca25f 83
84=head1 AUTHOR
85
86See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
87
88=head1 LICENSE
89
90You may distribute this code under the same terms as Perl itself.
91
92=cut
93# vim:sts=2 sw=2: