X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FMSSQL.pm;h=ea4b079694113dfeb37bc051e0535ce6e17ba24d;hb=b9ca4ff1e045a7863033012e98dc83b5dc95e26e;hp=58643644373521d430d82f60aec5ed885414fd44;hpb=ed7ab0f4ce1a9118ea6285ee562ef003085a6b64;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index 5864364..ea4b079 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -6,6 +6,7 @@ use warnings; use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/; use mro 'c3'; use Try::Tiny; +use namespace::clean; use List::Util(); @@ -129,7 +130,7 @@ sub _execute { # this should bring back the result of SELECT SCOPE_IDENTITY() we tacked # on in _prep_for_execute above - my ($identity) = eval { $sth->fetchrow_array }; + my ($identity) = try { $sth->fetchrow_array }; # SCOPE_IDENTITY failed, but we can do something else if ( (! $identity) && $self->_identity_method) { @@ -162,7 +163,7 @@ sub _select_args_to_query { if ( $sql !~ /^ \s* SELECT \s+ TOP \s+ \d+ \s+ /xi && - scalar $self->_parse_order_by ($attrs->{order_by}) + scalar $self->_parse_order_by ($attrs->{order_by}) ) { $self->throw_exception( 'An ordered subselect encountered - this is not safe! Please see "Ordered Subselects" in DBIx::Class::Storage::DBI::MSSQL @@ -197,7 +198,7 @@ sub _svp_rollback { sub datetime_parser_type { 'DBIx::Class::Storage::DBI::MSSQL::DateTime::Format' -} +} sub sqlt_type { 'SQLServer' } @@ -216,9 +217,10 @@ sub sql_maker { # stored procedures like xp_msver, or version detection failed for some # other reason. # So, we use a query to check if RNO is implemented. - $have_rno = 1 if (eval { local $@; ($self->_get_dbh - ->selectrow_array('SELECT row_number() OVER (ORDER BY rand())') - )[0] }); + try { + $self->_get_dbh->selectrow_array('SELECT row_number() OVER (ORDER BY rand())'); + $have_rno = 1; + }; } $self->{_sql_maker_opts} = { @@ -241,20 +243,18 @@ sub _ping { local $dbh->{RaiseError} = 1; local $dbh->{PrintError} = 0; - my $rc = 1; - try { + return try { $dbh->do('select 1'); + 1; } catch { - $rc = 0; + 0; }; - - return $rc; } package # hide from PAUSE DBIx::Class::Storage::DBI::MSSQL::DateTime::Format; -my $datetime_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T +my $datetime_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T my $smalldatetime_format = '%Y-%m-%d %H:%M:%S'; my ($datetime_parser, $smalldatetime_parser);