Commit | Line | Data |
56dca25f |
1 | package DBIx::Class::Storage::DBI::ADO; |
4ffa5700 |
2 | |
4a233f30 |
3 | use warnings; |
4 | use strict; |
5 | |
4ffa5700 |
6 | use base 'DBIx::Class::Storage::DBI'; |
56dca25f |
7 | use mro 'c3'; |
4ffa5700 |
8 | |
772a1a25 |
9 | use Sub::Name; |
7302b3e0 |
10 | use DBIx::Class::_Util qw( sigwarn_silencer modver_gt_or_eq ); |
772a1a25 |
11 | use namespace::clean; |
12 | |
56dca25f |
13 | =head1 NAME |
14 | |
15 | DBIx::Class::Storage::DBI::ADO - Support for L<DBD::ADO> |
16 | |
17 | =head1 DESCRIPTION |
18 | |
19 | This class provides a mechanism for discovering and loading a sub-class |
20 | for a specific ADO backend, as well as some workarounds for L<DBD::ADO>. It |
21 | should be transparent to the user. |
22 | |
23 | =cut |
24 | |
75d3bdb2 |
25 | sub _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 |
29 | sub _dbh_get_info { |
30 | my $self = shift; |
31 | |
052a832c |
32 | local $SIG{__WARN__} = sigwarn_silencer( |
33 | qr{^Missing argument in sprintf at \S+/ADO/GetInfo\.pm} |
34 | ); |
56dca25f |
35 | |
36 | $self->next::method(@_); |
4ffa5700 |
37 | } |
38 | |
772a1a25 |
39 | # Monkeypatch out the horrible warnings during global destruction. |
8892d8e5 |
40 | # A patch to DBD::ADO has been submitted as well, and it was fixed |
41 | # as of 2.99 |
772a1a25 |
42 | # https://rt.cpan.org/Ticket/Display.html?id=65563 |
43 | sub _init { |
8892d8e5 |
44 | unless ($DBD::ADO::__DBIC_MONKEYPATCH_CHECKED__) { |
45 | require DBD::ADO; |
46 | |
7302b3e0 |
47 | unless ( modver_gt_or_eq( 'DBD::ADO', '2.99' ) ) { |
8892d8e5 |
48 | no warnings 'redefine'; |
49 | my $disconnect = *DBD::ADO::db::disconnect{CODE}; |
50 | |
51 | *DBD::ADO::db::disconnect = subname 'DBD::ADO::db::disconnect' => sub { |
052a832c |
52 | local $SIG{__WARN__} = sigwarn_silencer( |
53 | qr/Not a Win32::OLE object|uninitialized value/ |
54 | ); |
8892d8e5 |
55 | $disconnect->(@_); |
772a1a25 |
56 | }; |
8892d8e5 |
57 | } |
58 | |
59 | $DBD::ADO::__DBIC_MONKEYPATCH_CHECKED__ = 1; |
772a1a25 |
60 | } |
61 | } |
62 | |
748eb620 |
63 | # Here I was just experimenting with ADO cursor types, left in as a comment in |
64 | # case you want to as well. See the DBD::ADO docs. |
9930caaf |
65 | #sub _prepare_sth { |
4ffa5700 |
66 | # my ($self, $dbh, $sql) = @_; |
67 | # |
68 | # my $sth = $self->disable_sth_caching |
69 | # ? $dbh->prepare($sql, { CursorType => 'adOpenStatic' }) |
70 | # : $dbh->prepare_cached($sql, { CursorType => 'adOpenStatic' }, 3); |
71 | # |
72 | # $self->throw_exception($dbh->errstr) if !$sth; |
73 | # |
74 | # $sth; |
75 | #} |
76 | |
a2bd3796 |
77 | =head1 FURTHER QUESTIONS? |
56dca25f |
78 | |
a2bd3796 |
79 | Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>. |
56dca25f |
80 | |
a2bd3796 |
81 | =head1 COPYRIGHT AND LICENSE |
56dca25f |
82 | |
a2bd3796 |
83 | This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE> |
84 | by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can |
85 | redistribute it and/or modify it under the same terms as the |
86 | L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>. |
56dca25f |
87 | |
88 | =cut |
a2bd3796 |
89 | |
90 | 1; |
91 | |
56dca25f |
92 | # vim:sts=2 sw=2: |