83d2a09b77be1d0a222f7bc8cf77c2da2ab289c8
[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   try {
15     my $dbtype = @{$self->_get_dbh
16       ->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})
17     }[2];
18
19     $dbtype =~ s/\W/_/gi;
20     my $subclass = "DBIx::Class::Storage::DBI::ADO::${dbtype}";
21     if ($self->load_optional_class($subclass) && !$self->isa($subclass)) {
22       bless $self, $subclass;
23       $self->_rebless;
24     }
25   };
26 }
27
28 # Here I was just experimenting with ADO cursor types, left in as a comment in
29 # case you want to as well. See the DBD::ADO docs.
30 #sub _dbh_sth {
31 #  my ($self, $dbh, $sql) = @_;
32 #
33 #  my $sth = $self->disable_sth_caching
34 #    ? $dbh->prepare($sql, { CursorType => 'adOpenStatic' })
35 #    : $dbh->prepare_cached($sql, { CursorType => 'adOpenStatic' }, 3);
36 #
37 #  $self->throw_exception($dbh->errstr) if !$sth;
38 #
39 #  $sth;
40 #}
41
42 1;