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