add placeholder support detection for mssql through dbd::sybase
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase / Microsoft_SQL_Server.pm
CommitLineData
98464041 1package DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server;
2
3use strict;
4use warnings;
2ad62d97 5
528accab 6use base qw/
eabab5d0 7 DBIx::Class::Storage::DBI::Sybase::Base
5a77aa8b 8 DBIx::Class::Storage::DBI::MSSQL
528accab 9/;
2ad62d97 10use mro 'c3';
98464041 11
7379eb67 12sub _rebless {
13 my $self = shift;
14 my $dbh = $self->_dbh;
15
16 my ($placeholders_supported) = eval {
17# There's also $dbh->{syb_dynamic_supported} but it can be inaccurate for this
18# purpose.
19 local $dbh->{PrintError} = 0;
20 $dbh->selectrow_array('select ?', {}, 1);
21 };
22
23 if (not $placeholders_supported) {
24 bless $self,
25 'DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars';
26 $self->_rebless;
27 }
28
29# LongReadLen doesn't work with MSSQL through DBD::Sybase, and the default is
30# huge on some versions of SQL server and can cause memory problems, so we
31# fix it up here.
32 my $text_size = eval { $self->_dbi_connect_info->[-1]->{LongReadLen} } ||
33 32768; # the DBD::Sybase default
34
35 $dbh->do("set textsize $text_size");
36}
37
98464041 381;
39
40=head1 NAME
41
5a77aa8b 42DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server - Support for Microsoft
43SQL Server via DBD::Sybase
98464041 44
45=head1 SYNOPSIS
46
9c541170 47This subclass supports MSSQL server connections via L<DBD::Sybase>.
98464041 48
7379eb67 49=head1 DESCRIPTION
98464041 50
7379eb67 51This driver tries to determine whether your version of L<DBD::Sybase> and
52supporting libraries (usually FreeTDS) support using placeholders, if not the
53storage will be reblessed to
54L<DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::NoBindVars>.
d4483998 55
7379eb67 56The MSSQL specific functionality is provided by
57L<DBIx::Class::Storage::DBI::MSSQL>.
98464041 58
5a77aa8b 59=head1 AUTHOR
98464041 60
5a77aa8b 61See L<DBIx::Class/CONTRIBUTORS>.
98464041 62
63=head1 LICENSE
64
65You may distribute this code under the same terms as Perl itself.
66
67=cut