Make the insert_returning capability private (and saner naming)
[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
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   return if ref $self ne __PACKAGE__;
17
18   if (not $self->_typeless_placeholders_supported) {
19     require
20       DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars;
21     bless $self,
22       'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars';
23     $self->_rebless;
24   }
25 }
26
27 sub _run_connection_actions {
28   my $self = shift;
29
30   # LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is
31   # huge on some versions of SQL server and can cause memory problems, so we
32   # fix it up here (see ::DBI::Sybase.pm)
33   $self->set_textsize;
34
35   $self->next::method(@_);
36 }
37
38 sub _dbh_begin_work {
39   my $self = shift;
40
41   $self->_get_dbh->do('BEGIN TRAN');
42 }
43
44 sub _dbh_commit {
45   my $self = shift;
46   my $dbh  = $self->_dbh
47     or $self->throw_exception('cannot COMMIT on a disconnected handle');
48   $dbh->do('COMMIT');
49 }
50
51 sub _dbh_rollback {
52   my $self = shift;
53   my $dbh  = $self->_dbh
54     or $self->throw_exception('cannot ROLLBACK on a disconnected handle');
55   $dbh->do('ROLLBACK');
56 }
57
58 sub _populate_server_info {
59   my $self = shift;
60
61   my $info = $self->next::method(@_);
62
63   my $product_version = $self->_get_dbh->selectrow_hashref('xp_msver ProductVersion');
64
65   if ((my $version = $data->{Character_Value}) =~ /^(\d+)\./) {
66     $info->{dbms_ver} = $version;
67   } else {
68     $self->throw_exception(q{
69 MSSQL Version Retrieval Failed, Your ProductVersion's Character_Value is missing
70 or malformed!
71     });
72   }
73
74   return $info;
75 }
76
77 1;
78
79 =head1 NAME
80
81 DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server - Support for Microsoft
82 SQL Server via DBD::Sybase
83
84 =head1 SYNOPSIS
85
86 This subclass supports MSSQL server connections via L<DBD::Sybase>.
87
88 =head1 DESCRIPTION
89
90 This driver tries to determine whether your version of L<DBD::Sybase> and
91 supporting libraries (usually FreeTDS) support using placeholders, if not the
92 storage will be reblessed to
93 L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars>.
94
95 The MSSQL specific functionality is provided by
96 L<DBIx::Class::Storage::DBI::MSSQL>.
97
98 =head1 AUTHOR
99
100 See L<DBIx::Class/CONTRIBUTORS>.
101
102 =head1 LICENSE
103
104 You may distribute this code under the same terms as Perl itself.
105
106 =cut