X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSybase%2FBase.pm;h=2284289662c0e88e26fffb55c93de57063cbe554;hb=44e538d00c41e69899b48178c9dede95e2ef7e77;hp=b375a8ccfb9b4db4fc6cb24c0a3327f0108979db;hpb=d8a35ad60f5c359f6185854646392f194b393a48;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm index b375a8c..2284289 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm @@ -1,5 +1,4 @@ -package # hide from PAUSE - DBIx::Class::Storage::DBI::Sybase::Base; +package DBIx::Class::Storage::DBI::Sybase::Base; use strict; use warnings; @@ -12,6 +11,15 @@ use mro 'c3'; DBIx::Class::Storage::DBI::Sybase::Base - Common functionality for drivers using DBD::Sybase +=head1 DESCRIPTION + +This is the base class for L and +L. It provides some +utility methods related to L and the supported functions of the +database you are connecting to. + +=head1 METHODS + =cut sub _ping { @@ -27,7 +35,14 @@ sub _ping { return $@ ? 0 : 1; } -sub _placeholders_supported { +=head2 placeholders_supported + +Whether or not string placeholders work. Does not check for implicit conversion +errors, see L. + +=cut + +sub placeholders_supported { my $self = shift; my $dbh = $self->last_dbh; @@ -36,11 +51,77 @@ sub _placeholders_supported { # purpose. local $dbh->{PrintError} = 0; local $dbh->{RaiseError} = 1; + $dbh->selectrow_array('select ?', {}, 1); + }; +} + +=head2 placeholders_with_type_conversion_supported + +=cut + +sub placeholders_with_type_conversion_supported { + my $self = shift; + my $dbh = $self->_dbh; + + return eval { + local $dbh->{PrintError} = 0; + local $dbh->{RaiseError} = 1; # this specifically tests a bind that is NOT a string $dbh->selectrow_array('select 1 where 1 = ?', {}, 1); }; } +sub _set_max_connect { + my $self = shift; + my $val = shift || 256; + + my $dsn = $self->_dbi_connect_info->[0]; + + return if ref($dsn) eq 'CODE'; + + if ($dsn !~ /maxConnect=/) { + $self->_dbi_connect_info->[0] = "$dsn;maxConnect=$val"; + my $connected = defined $self->_dbh; + $self->disconnect; + $self->ensure_connected if $connected; + } +} + +=head2 using_freetds + +Whether or not L was compiled against FreeTDS. If false, it means +the Sybase OpenClient libraries were used. + +=cut + +sub using_freetds { + my $self = shift; + + return $self->_dbh->{syb_oc_version} =~ /freetds/i; +} + +=head2 set_textsize + +When using FreeTDS and/or MSSQL, C<< $dbh->{LongReadLen} >> is not available, +use this function instead. It does: + + $dbh->do("SET TEXTSIZE $bytes"); + +Takes the number of bytes, or uses the C value from your +L if omitted. + +=cut + +sub set_textsize { + my $self = shift; + my $text_size = shift || + eval { $self->_dbi_connect_info->[-1]->{LongReadLen} }; + + return unless defined $text_size; + + $self->_dbh->do("SET TEXTSIZE $text_size"); +} + 1; =head1 AUTHORS