X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSybase.pm;h=abf15bfbcfd2b243b20c0a7adc7f27ae5050e5a3;hb=e56b1c2d9508b46a185b404413a85cd738e187a5;hp=77b77e2273395f0e72f815bc7c463cd6dca44770;hpb=95787afeb4ecec13279ab2fb26a407c0f971b7df;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 77b77e2..abf15bf 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -2,6 +2,8 @@ package DBIx::Class::Storage::DBI::Sybase; use strict; use warnings; +use Try::Tiny; +use namespace::clean; use base qw/DBIx::Class::Storage::DBI/; @@ -22,13 +24,13 @@ L sub _rebless { my $self = shift; - my $dbtype = eval { - @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] + my $dbtype; + try { + $dbtype = @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] + } catch { + $self->throw_exception("Unable to estable connection to determine database type: $_") }; - $self->throw_exception("Unable to estable connection to determine database type: $@") - if $@; - if ($dbtype) { $dbtype =~ s/\W/_/gi; @@ -53,17 +55,17 @@ sub _ping { if ($dbh->{syb_no_child_con}) { # if extra connections are not allowed, then ->ping is reliable - my $ping = eval { $dbh->ping }; - return $@ ? 0 : $ping; + return try { $dbh->ping } catch { 0; }; } - eval { + return try { # XXX if the main connection goes stale, does opening another for this statement # really determine anything? $dbh->do('select 1'); + 1; + } catch { + 0; }; - - return $@ ? 0 : 1; } sub _set_max_connect { @@ -103,15 +105,18 @@ 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, lastly falls back to the C<32768> which -is the L default. +L if omitted, lastly falls +back to the C<32768> which is the L default. =cut sub set_textsize { my $self = shift; - my $text_size = shift || - eval { $self->_dbi_connect_info->[-1]->{LongReadLen} } || + my $text_size = + shift + || + try { $self->_dbi_connect_info->[-1]->{LongReadLen} } + || 32768; # the DBD::Sybase default return unless defined $text_size;