made commit/rollback when disconnected an exception
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase / Microsoft_SQL_Server.pm
1 package DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server;
2
3 use strict;
4 use warnings;
5
6 use base qw/
7   DBIx::Class::Storage::DBI::Sybase::Common
8   DBIx::Class::Storage::DBI::MSSQL
9 /;
10 use mro 'c3';
11
12 sub _rebless {
13   my $self = shift;
14   my $dbh  = $self->_get_dbh;
15
16   if (not $self->_typeless_placeholders_supported) {
17     bless $self,
18       'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars';
19     $self->_rebless;
20   }
21 }
22
23 sub _init {
24   my $self = shift;
25
26   # LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is
27   # huge on some versions of SQL server and can cause memory problems, so we
28   # fix it up here (see Sybase/Common.pm)
29   $self->set_textsize;
30 }
31
32 sub _dbh_begin_work {
33   my $self = shift;
34
35   $self->_get_dbh->do('BEGIN TRAN');
36 }
37
38 sub _dbh_commit {
39   my $self = shift;
40   my $dbh  = $self->_dbh
41     or $self->throw_exception('cannot COMMIT on a disconnected handle');
42   $dbh->do('COMMIT');
43 }
44
45 sub _dbh_rollback {
46   my $self = shift;
47   my $dbh  = $self->_dbh
48     or $self->throw_exception('cannot ROLLBACK on a disconnected handle');
49   $dbh->do('ROLLBACK');
50 }
51
52 1;
53
54 =head1 NAME
55
56 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server - Support for Microsoft
57 SQL Server via DBD::Sybase
58
59 =head1 SYNOPSIS
60
61 This subclass supports MSSQL server connections via L<DBD::Sybase>.
62
63 =head1 DESCRIPTION
64
65 This driver tries to determine whether your version of L<DBD::Sybase> and
66 supporting libraries (usually FreeTDS) support using placeholders, if not the
67 storage will be reblessed to
68 L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars>.
69
70 The MSSQL specific functionality is provided by
71 L<DBIx::Class::Storage::DBI::MSSQL>.
72
73 =head1 AUTHOR
74
75 See L<DBIx::Class/CONTRIBUTORS>.
76
77 =head1 LICENSE
78
79 You may distribute this code under the same terms as Perl itself.
80
81 =cut