fix and regression test for RT #62642
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ADO.pm
1 package # hide from PAUSE
2     DBIx::Class::Storage::DBI::ADO;
3
4 use base 'DBIx::Class::Storage::DBI';
5 use Try::Tiny;
6 use namespace::clean;
7
8 sub _rebless {
9   my $self = shift;
10
11 # check for MSSQL
12 # XXX This should be using an OpenSchema method of some sort, but I don't know
13 # how.
14 # Current version is stolen from Sybase.pm
15   try {
16     my $dbtype = @{$self->_get_dbh
17       ->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})
18     }[2];
19
20     $dbtype =~ s/\W/_/gi;
21     my $subclass = "DBIx::Class::Storage::DBI::ADO::${dbtype}";
22     if ($self->load_optional_class($subclass) && !$self->isa($subclass)) {
23       bless $self, $subclass;
24       $self->_rebless;
25     }
26   };
27 }
28
29 # Here I was just experimenting with ADO cursor types, left in as a comment in
30 # case you want to as well. See the DBD::ADO docs.
31 #sub _dbh_sth {
32 #  my ($self, $dbh, $sql) = @_;
33 #
34 #  my $sth = $self->disable_sth_caching
35 #    ? $dbh->prepare($sql, { CursorType => 'adOpenStatic' })
36 #    : $dbh->prepare_cached($sql, { CursorType => 'adOpenStatic' }, 3);
37 #
38 #  $self->throw_exception($dbh->errstr) if !$sth;
39 #
40 #  $sth;
41 #}
42
43 1;