'namespace::clean' => '0.24',
'Scope::Guard' => '0.03',
'SQL::Abstract' => '1.81',
- 'Try::Tiny' => '0.07',
# Technically this is not a core dependency - it is only required
# by the MySQL codepath. However this particular version is bundled
use warnings;
use base qw/DBIx::Class/;
use DBIx::Class::Carp;
-use DBIx::Class::_Util 'dbic_internal_try';
-use Try::Tiny;
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch );
use namespace::clean;
=head1 NAME
my $preferred_method = sprintf($method_fmt, $info->{ _ic_dt_method });
my $method = $parser->can($preferred_method) || sprintf($method_fmt, 'datetime');
- return dbic_internal_try {
+ dbic_internal_try {
$parser->$method($value);
}
- catch {
+ dbic_internal_catch {
$self->throw_exception ("Error while inflating '$value' for $info->{__dbic_colname} on ${self}: $_")
unless $info->{datetime_undef_if_invalid};
+
undef; # rv
};
}
use base qw/DBIx::Class/;
use Scalar::Util qw/weaken blessed/;
-use Try::Tiny;
use DBIx::Class::_Util qw( UNRESOLVABLE_CONDITION fail_on_internal_call );
use namespace::clean;
use strict;
use warnings;
-use Try::Tiny;
-use DBIx::Class::_Util 'dbic_internal_try';
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch );
use namespace::clean;
our %_pod_inherit_config =
my $f_rsrc = dbic_internal_try {
$f_class->result_source;
}
- catch {
+ dbic_internal_catch {
$class->throw_exception(
"Foreign class '$f_class' does not seem to be a Result class "
. "(or it simply did not load entirely due to a circular relation chain): $_"
use strict;
use warnings;
use DBIx::Class::Carp;
-use Try::Tiny;
-use DBIx::Class::_Util 'dbic_internal_try';
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch );
use namespace::clean;
our %_pod_inherit_config =
unless $r->columns;
$r;
}
- catch {
+ dbic_internal_catch {
$class->throw_exception(
"Foreign class '$f_class' does not seem to be a Result class "
. "(or it simply did not load entirely due to a circular relation chain)"
use DBIx::Class::ResultClass::HashRefInflator;
use Scalar::Util qw( blessed reftype );
use DBIx::Class::_Util qw(
- dbic_internal_try dump_value
+ dbic_internal_try dbic_internal_catch dump_value
fail_on_internal_wantarray fail_on_internal_call UNRESOLVABLE_CONDITION
);
use DBIx::Class::SQLMaker::Util qw( normalize_sqla_condition extract_equality_conditions );
-use Try::Tiny;
BEGIN {
# De-duplication in _merge_attr() is disabled, but left in for reference
$alias
);
}
- catch {
+ dbic_internal_catch {
push @fc_exceptions, $_ if $_ =~ /\bFilterColumn\b/;
};
}
use base 'DBIx::Class';
-use Try::Tiny;
-
use DBIx::Class::ResultSource::RowParser::Util qw(
assemble_simple_parser
assemble_collapsing_parser
use base 'DBIx::Class';
use DBIx::Class::Carp;
-use Try::Tiny;
use Scalar::Util qw( weaken blessed refaddr );
use DBIx::Class::_Util qw(
refdesc refcount quote_sub scope_guard
- is_exception dbic_internal_try
+ is_exception dbic_internal_try dbic_internal_catch
fail_on_internal_call emit_loud_diag
);
use Devel::GlobalDestruction;
return dbic_internal_try {
$rs_class->result_source
- } catch {
+ } dbic_internal_catch {
$me->throw_exception (
"Attempt to load_namespaces() class $rs_class failed - are you sure this is a real Result Class?: $_"
);
dbic_internal_try {
$self->ensure_class_loaded ($storage_class);
}
- catch {
+ dbic_internal_catch {
$self->throw_exception(
"Unable to load storage class ${storage_class}: $_"
);
1;
}
- catch {
+ dbic_internal_catch {
# We call this to get the necessary warnings emitted and disregard the RV
# as it's definitely an exception if we got as far as this catch{} block
is_exception(
dbic_internal_try {
require DBIx::Class::ResultSetProxy;
}
- catch {
+ dbic_internal_catch {
$self->throw_exception
("No arguments to load_classes and couldn't load DBIx::Class::ResultSetProxy ($_)")
};
use DBIx::Class::Storage::BlockRunner;
use Scalar::Util qw/blessed weaken/;
use DBIx::Class::Storage::TxnScopeGuard;
-use DBIx::Class::_Util qw( dbic_internal_try fail_on_internal_call );
-use Try::Tiny;
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch fail_on_internal_call );
use namespace::clean;
__PACKAGE__->mk_group_accessors(simple => qw/debug schema transaction_depth auto_savepoint savepoints/);
my $rs;
try {
$rs = $schema->txn_do($coderef);
- } catch {
+ } dbic_internal_catch {
my $error = shift;
# Transaction failed
die "something terrible has happened!"
dbic_internal_try {
$self->txn_rollback; 1
}
- catch {
+ dbic_internal_catch {
$rbe = $_;
my $cfg = dbic_internal_try {
Config::Any->load_files({ files => [$profile], use_ext => 1 });
- } catch {
+ } dbic_internal_catch {
# sanitize the error message a bit
$_ =~ s/at \s+ .+ Storage\.pm \s line \s \d+ $//x;
$self->throw_exception("Failure processing \$ENV{DBIC_TRACE_PROFILE}: $_");
# a better fix. This is another yak to shave... :(
dbic_internal_try {
DBIx::Class::Storage::Debug::PrettyPrint->new(@pp_args);
- } catch {
+ } dbic_internal_catch {
$self->throw_exception($_);
}
}
use DBIx::Class::Carp;
use Context::Preserve 'preserve_context';
-use DBIx::Class::_Util qw( is_exception qsub dbic_internal_try );
+use DBIx::Class::_Util qw( is_exception qsub dbic_internal_try dbic_internal_catch );
use Scalar::Util qw(weaken blessed reftype);
-use Try::Tiny;
use Moo;
use namespace::clean;
$txn_begin_ok = 1;
}
$cref->( @$args );
- } catch {
+ } dbic_internal_catch {
$run_err = $_;
(); # important, affects @_ below
};
$storage->txn_commit;
1;
}
- catch {
+ dbic_internal_catch {
$run_err = $_;
};
}
use DBIx::Class::Carp;
use Scalar::Util qw/refaddr weaken reftype blessed/;
use Context::Preserve 'preserve_context';
-use Try::Tiny;
use SQL::Abstract qw(is_plain_value is_literal_value);
use DBIx::Class::_Util qw(
quote_sub perlstring serialize dump_value
- dbic_internal_try
+ dbic_internal_try dbic_internal_catch
detected_reinvoked_destructor scope_guard
mkdir_p
);
my $server_version = dbic_internal_try {
$self->_get_server_version
- } catch {
+ } dbic_internal_catch {
# driver determination *may* use this codepath
# in which case we must rethrow
$self->throw_exception($_) if $self->{_in_determine_driver};
$self->throw_exception (sprintf ("Don't know how to process conection actions of type '%s'", ref($call)) );
}
}
- catch {
+ dbic_internal_catch {
if ( $method_prefix =~ /^connect/ ) {
# this is an on_connect cycle - we can't just throw while leaving
# a handle in an undefined state in our storage object
$dbh_error_handler_installer->($self, $dbh);
}
}
- catch {
+ dbic_internal_catch {
$self->throw_exception("DBI Connection failed: $_")
};
@ir_container = $sth->fetchrow_array;
$sth->finish;
- } catch {
+ } dbic_internal_catch {
# Evict the $sth from the cache in case we got here, since the finish()
# is crucial, at least on older Firebirds, possibly on other engines too
#
$tuple_status,
);
}
- catch {
+ dbic_internal_catch {
$err = shift;
};
dbic_internal_try {
$sth->finish
}
- catch {
+ dbic_internal_catch {
$err = shift unless defined $err
};
$sth->execute foreach 1..$count;
}
- catch {
+ dbic_internal_catch {
$err = shift;
};
dbic_internal_try {
$sth->finish
}
- catch {
+ dbic_internal_catch {
$err = shift unless defined $err;
};
$result{$col_name} = \%column_info;
}
- } catch {
+ } dbic_internal_catch {
%result = ();
};
# do a dbh_do cycle here, as we need some error checking in
# place (even though we will ignore errors)
$self->dbh_do (sub { $_[1]->do($line) });
- } catch {
+ } dbic_internal_catch {
carp qq{$_ (running "${line}")};
};
$self->_query_end($line);
/;
use mro 'c3';
-use Try::Tiny;
-use DBIx::Class::_Util qw( dbic_internal_try sigwarn_silencer );
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch sigwarn_silencer );
use namespace::clean;
__PACKAGE__->mk_group_accessors(simple => qw/
$dbh->do('select 1');
1;
}
- catch {
+ dbic_internal_catch {
# MSSQL is *really* annoying wrt multiple active resultsets,
# and this may very well be the reason why the _ping failed
#
DBIx::Class::Storage::DBI::Firebird::Common
/;
use mro 'c3';
-use Try::Tiny;
-use DBIx::Class::_Util 'dbic_internal_try';
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch );
use namespace::clean;
=head1 NAME
dbic_internal_try {
$self->_dbh->do("ROLLBACK TO SAVEPOINT $name")
}
- catch {
+ dbic_internal_catch {
# Firebird ODBC driver bug, ignore
if (not /Unable to fetch information about the error/) {
$self->throw_exception($_);
/;
use mro 'c3';
use Scalar::Util 'reftype';
-use Try::Tiny;
-use DBIx::Class::_Util 'dbic_internal_try';
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch );
use DBIx::Class::Carp;
use namespace::clean;
local $dbh->{RaiseError} = 1;
local $dbh->{PrintError} = 0;
$dbh->do('SELECT @@IDENTITY');
- } catch {
+ }
+ dbic_internal_catch {
$self->throw_exception (
'Your drivers do not seem to support dynamic cursors (odbc_cursortype => 2).'
. (
use Hash::Merge;
use List::Util qw( min max );
use Context::Preserve 'preserve_context';
-use Try::Tiny;
-use DBIx::Class::_Util 'dbic_internal_try';
use namespace::clean -except => 'meta';
use DBI ();
use MooseX::Types::Moose qw/Num Int ClassName HashRef/;
use DBIx::Class::Storage::DBI::Replicated::Types 'DBICStorageDBI';
-use DBIx::Class::_Util 'dbic_internal_try';
-use Try::Tiny;
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch );
use namespace::clean -except => 'meta';
sub _safely {
my ($self, $replicant, $name, $code) = @_;
- return dbic_internal_try {
+ dbic_internal_try {
$code->();
1;
- } catch {
+ }
+ dbic_internal_catch {
$replicant->debugobj->print(sprintf(
"Exception trying to $name for replicant %s, error is %s",
$replicant->_dbi_connect_info->[0], $_)
);
+
+ # rv
undef;
};
}
use warnings;
use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/;
use mro 'c3';
-use DBIx::Class::_Util 'dbic_internal_try';
-use Try::Tiny;
-use namespace::clean;
__PACKAGE__->mk_group_accessors(simple => qw/_identity/);
__PACKAGE__->sql_limit_dialect ('RowNumberOver');
return @row;
}
-# this sub stolen from MSSQL
-
sub build_datetime_parser {
- my $self = shift;
- dbic_internal_try {
- require DateTime::Format::Strptime;
- }
- catch {
- $self->throw_exception("Couldn't load DateTime::Format::Strptime: $_");
- };
- return DateTime::Format::Strptime->new( pattern => '%Y-%m-%d %H:%M:%S.%6N' );
+ require DateTime::Format::Strptime;
+
+ DateTime::Format::Strptime->new( pattern => '%Y-%m-%d %H:%M:%S.%6N' );
}
=head2 connect_call_datetime_setup
use mro 'c3';
use SQL::Abstract 'is_plain_value';
-use DBIx::Class::_Util qw(modver_gt_or_eq sigwarn_silencer dbic_internal_try);
+use DBIx::Class::_Util qw(
+ modver_gt_or_eq sigwarn_silencer
+ dbic_internal_try dbic_internal_catch
+);
use DBIx::Class::Carp;
-use Try::Tiny;
use namespace::clean;
__PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::SQLite');
$really_not_in_txn = 1;
}
- catch {
+ dbic_internal_catch {
$really_not_in_txn = ( $_[0] =~ qr/transaction within a transaction/
? 0
: undef
use strict;
use warnings;
-use DBIx::Class::_Util 'dbic_internal_try';
-use Try::Tiny;
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch );
use namespace::clean;
use base qw/DBIx::Class::Storage::DBI/;
}
$name; # RV
- } catch {
+ }
+ dbic_internal_catch {
$self->throw_exception("Unable to establish connection to determine database type: $_")
};
}
use mro 'c3';
use DBIx::Class::Carp;
use Scalar::Util qw/blessed weaken/;
-use Try::Tiny;
use Context::Preserve 'preserve_context';
-use DBIx::Class::_Util qw( sigwarn_silencer dbic_internal_try dump_value scope_guard set_subname );
+use DBIx::Class::_Util qw(
+ sigwarn_silencer dbic_internal_try dbic_internal_catch
+ dump_value scope_guard set_subname
+);
use namespace::clean;
__PACKAGE__->sql_limit_dialect ('GenericSubQ');
$guard->commit;
$bulk->_query_end($sql);
- } catch {
- $exception = shift;
+ }
+ dbic_internal_catch {
+ $exception = $_;
};
DBD::Sybase::set_cslib_cb($orig_cslib_cb);
sub _update_blobs {
my ($self, $source, $blob_cols, $where) = @_;
- my @primary_cols = dbic_internal_try
- { $source->_pri_cols_or_die }
- catch {
+ my @primary_cols =
+ dbic_internal_try {
+ $source->_pri_cols_or_die
+ }
+ dbic_internal_catch {
$self->throw_exception("Cannot update TEXT/IMAGE column(s): $_")
- };
+ }
+ ;
my @pks_to_update;
if (
my @primary_cols = dbic_internal_try
{ $source->_pri_cols_or_die }
- catch {
+ dbic_internal_catch {
$self->throw_exception("Cannot update TEXT/IMAGE column(s): $_")
};
$sth->func('ct_finish_send') or die $sth->errstr;
}
- catch {
+ dbic_internal_catch {
if ($self->_using_freetds) {
$self->throw_exception (
"TEXT/IMAGE operation failed, probably because you are using FreeTDS: $_"
refdesc refcount hrefaddr set_subname get_subname describe_class_methods
scope_guard detected_reinvoked_destructor emit_loud_diag
true false
- is_exception dbic_internal_try visit_namespaces
+ is_exception dbic_internal_try dbic_internal_catch visit_namespaces
quote_sub qsub perlstring serialize deep_clone dump_value uniq
parent_dir mkdir_p
UNRESOLVABLE_CONDITION
{
my $callstack_state;
- # Recreate the logic of try(), while reusing the catch()/finally() as-is
- #
- # FIXME: We need to move away from Try::Tiny entirely (way too heavy and
- # yes, shows up ON TOP of profiles) but this is a batle for another maint
+ # Recreate the logic of Try::Tiny, but without the crazy Sub::Name
+ # invocations and without support for finally() altogether
+ # ( yes, these days Try::Tiny is so "tiny" it shows *ON TOP* of most
+ # random profiles https://youtu.be/PYCbumw0Fis?t=1919 )
sub dbic_internal_try (&;@) {
my $try_cref = shift;
for my $arg (@_) {
- if( ref($arg) eq 'Try::Tiny::Catch' ) {
+ croak 'dbic_internal_try() may not be followed by multiple dbic_internal_catch() blocks'
+ if $catch_cref;
- croak 'dbic_internal_try() may not be followed by multiple catch() blocks'
- if $catch_cref;
+ ($catch_cref = $$arg), next
+ if ref($arg) eq 'DBIx::Class::_Util::Catch';
- $catch_cref = $$arg;
- }
- elsif ( ref($arg) eq 'Try::Tiny::Finally' ) {
- croak 'dbic_internal_try() does not support finally{}';
- }
- else {
- croak(
- 'dbic_internal_try() encountered an unexpected argument '
- . "'@{[ defined $arg ? $arg : 'UNDEF' ]}' - perhaps "
- . 'a missing semi-colon before or ' # trailing space important
- );
- }
+ croak( 'Mixing dbic_internal_try() with Try::Tiny::catch() is not supported' )
+ if ref($arg) eq 'Try::Tiny::Catch';
+
+ croak( 'dbic_internal_try() does not support finally{}' )
+ if ref($arg) eq 'Try::Tiny::Finally';
+
+ croak(
+ 'dbic_internal_try() encountered an unexpected argument '
+ . "'@{[ defined $arg ? $arg : 'UNDEF' ]}' - perhaps "
+ . 'a missing semi-colon before or ' # trailing space important
+ );
}
my $wantarray = wantarray;
my $preexisting_exception = $@;
my @ret;
- my $all_good = eval {
+ my $saul_goodman = eval {
$@ = $preexisting_exception;
local $callstack_state->{in_internal_try} = 1
my $exception = $@;
$@ = $preexisting_exception;
- if ( $all_good ) {
+ if ( $saul_goodman ) {
return $wantarray ? @ret : $ret[0]
}
elsif ( $catch_cref ) {
return;
}
- sub in_internal_try { !! $callstack_state->{in_internal_try} }
+ sub dbic_internal_catch (&;@) {
+
+ croak( 'Useless use of bare dbic_internal_catch()' )
+ unless wantarray;
+
+ croak( 'dbic_internal_catch() must receive exactly one argument at end of expression' )
+ if @_ > 1;
+
+ bless(
+ \( $_[0] ),
+ 'DBIx::Class::_Util::Catch'
+ ),
+ }
+
+ sub in_internal_try () {
+ !! $callstack_state->{in_internal_try}
+ }
}
{
use Exporter;
use SQL::Translator::Utils qw(debug normalize_name);
use DBIx::Class::Carp qw/^SQL::Translator|^DBIx::Class|^Try::Tiny/;
-use DBIx::Class::_Util 'dbic_internal_try';
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch );
use Class::C3::Componentised;
use Scalar::Util 'blessed';
-use Try::Tiny;
use namespace::clean;
use base qw(Exporter);
if (!ref $dbicschema) {
dbic_internal_try {
Class::C3::Componentised->ensure_class_loaded($dbicschema)
- } catch {
+ }
+ dbic_internal_catch {
DBIx::Class::Exception->throw("Can't load $dbicschema: $_");
}
}
return populate_weakregistry ($weak_registry, $obj );
};
- require Try::Tiny;
- for my $func (qw/try catch finally/) {
- my $orig = \&{"Try::Tiny::$func"};
- *{"Try::Tiny::$func"} = sub (&;@) {
+
+ for my $func (qw( dbic_internal_try dbic_internal_catch )) {
+ my $orig = \&{"DBIx::Class::_Util::$func"};
+ *{"DBIx::Class::_Util"} = sub (&;@) {
populate_weakregistry( $weak_registry, $_[0] );
goto $orig;
}
}
+ if ( eval { require Try::Tiny } ) {
+ for my $func (qw( try catch finally )) {
+ my $orig = \&{"Try::Tiny::$func"};
+ *{"Try::Tiny::$func"} = sub (&;@) {
+ populate_weakregistry( $weak_registry, $_[0] );
+ goto $orig;
+ }
+ }
+ }
+
+
# Some modules are known to install singletons on-load
# Load them and empty the registry
use Test::Exception;
use Test::More;
-use Try::Tiny;
use DBIx::Class::_Util 'set_subname';
use DBICTest;
use Test::Exception;
use Test::More;
-use Try::Tiny;
use DBICTest::Schema::BindType;
BEGIN {
'multi-part LOB equality query was not cached',
) if $size eq 'large';
is @objs, 1, 'One row found matching on both LOBs';
- ok (try { $objs[0]->blob }||'' eq "blob:$str", 'blob inserted/retrieved correctly');
- ok (try { $objs[0]->clob }||'' eq "clob:$str", 'clob inserted/retrieved correctly');
- ok (try { $objs[0]->clb2 }||'' eq "clb2:$str", "clb2 inserted correctly");
- ok (try { $objs[0]->blb2 }||'' eq "blb2:$str", "blb2 inserted correctly");
+
+ for my $type (qw( blob clob clb2 blb2 )) {
+ is (
+ eval { $objs[0]->$type },
+ "$type:$str",
+ "$type inserted/retrieved correctly"
+ );
+ }
{
local $TODO = '-like comparison on blobs not tested before ora 10 (fails on 8i)'
@objs = $rs->search({ blob => "updated blob", clob => 'updated clob' })->all;
is @objs, 1, 'found updated row';
- ok (try { $objs[0]->blob }||'' eq "updated blob", 'blob updated/retrieved correctly');
- ok (try { $objs[0]->clob }||'' eq "updated clob", 'clob updated/retrieved correctly');
- ok (try { $objs[0]->clb2 }||'' eq "updated clb2", "clb2 updated correctly");
- ok (try { $objs[0]->blb2 }||'' eq "updated blb2", "blb2 updated correctly");
+
+ for my $type (qw( blob clob clb2 blb2 )) {
+ is (
+ eval { $objs[0]->$type },
+ "updated $type",
+ "$type updated/retrieved correctly"
+ );
+ }
lives_ok {
$rs->search({ id => $id })
@objs = $rs->search({ blob => 're-updated blob', clob => 're-updated clob' })->all;
is @objs, 1, 'found updated row';
- ok (try { $objs[0]->blob }||'' eq 're-updated blob', 'blob updated/retrieved correctly');
- ok (try { $objs[0]->clob }||'' eq 're-updated clob', 'clob updated/retrieved correctly');
+
+ for my $type (qw( blob clob )) {
+ is (
+ eval { $objs[0]->$type },
+ "re-updated $type",
+ "$type updated/retrieved correctly"
+ );
+ }
lives_ok {
$rs->search({ blob => "re-updated blob", clob => "re-updated clob" })
use Test::More;
use Test::Exception;
-use Try::Tiny;
use DBICTest;
is $schema->storage->sql_maker->name_sep, $name_sep,
'name_sep detection';
-my $have_rno = try {
+my $have_rno = eval {
$dbh->selectrow_array(
-"SELECT row_number() OVER (ORDER BY 1) FROM sysibm${name_sep}sysdummy1"
+ "SELECT row_number() OVER (ORDER BY 1) FROM sysibm${name_sep}sysdummy1"
);
1;
};
use Test::More;
use Test::Exception;
use Test::Warn;
-use Try::Tiny;
use DBICTest;
+use DBIx::Class::_Util qw( dbic_internal_try dbic_internal_catch );
my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PASS/};
my $opts = $opts{$opts_name}{opts};
$schema = DBICTest::Schema->connect($dsn, $user, $pass, $opts);
- try {
+ dbic_internal_try {
$schema->storage->ensure_connected
}
- catch {
+ dbic_internal_catch {
if ($opts{$opts_name}{required}) {
die "on_connect_call option '$opts_name' is not functional: $_";
}
$row = $rs->create({ amount => 100 });
} 'inserted a money value';
- cmp_ok ((try { $rs->find($row->id)->amount })||0, '==', 100,
- 'money value round-trip');
+ cmp_ok (
+ ( eval { $rs->find($row->id)->amount } ) || 0,
+ '==',
+ 100,
+ 'money value round-trip'
+ );
lives_ok {
$row->update({ amount => 200 });
} 'updated a money value';
- cmp_ok ((try { $rs->find($row->id)->amount })||0, '==', 200,
- 'updated money value round-trip');
+ cmp_ok (
+ ( eval { $rs->find($row->id)->amount } ) || 0,
+ '==',
+ 200,
+ 'updated money value round-trip'
+ );
lives_ok {
$row->update({ amount => undef });
} 'updated a money value to NULL';
- is try { $rs->find($row->id)->amount }, undef,
- 'updated money value to NULL round-trip';
+ lives_ok {
+ is(
+ $rs->find($row->id)->amount,
+ undef,
+ 'updated money value to NULL round-trip'
+ );
+ }
}
}
use Test::More;
use Test::Exception;
-use Try::Tiny;
use DBICTest;
$schema->storage->dbh_do (sub {
my ($storage, $dbh) = @_;
- try { local $^W = 0; $dbh->do("DROP TABLE artist") };
+ eval { local $^W = 0; $dbh->do("DROP TABLE artist") };
$dbh->do(<<'SQL');
CREATE TABLE artist (
artistid INT IDENTITY NOT NULL,
$schema->storage->dbh_do (sub {
my ($storage, $dbh) = @_;
- try { local $^W = 0; $dbh->do("DROP TABLE artist_guid") };
+ eval { local $^W = 0; $dbh->do("DROP TABLE artist_guid") };
$dbh->do(<<"SQL");
CREATE TABLE artist_guid (
artistid UNIQUEIDENTIFIER NOT NULL,
$schema->storage->dbh_do (sub {
my ($storage, $dbh) = @_;
- try { local $^W = 0; $dbh->do("DROP TABLE varying_max_test") };
+ eval { local $^W = 0; $dbh->do("DROP TABLE varying_max_test") };
$dbh->do("
CREATE TABLE varying_max_test (
id INT IDENTITY NOT NULL,
my $rs2 = $schema->resultset('Artist')->search({}, { order_by => 'name' });
while ($rs1->next) {
- ok try { $rs2->next }, 'multiple active cursors';
+ lives_ok { ok $rs2->next } 'multiple active cursors';
}
# test bug where ADO blows up if the first bindparam is shorter than the second
$row->discard_changes;
} 're-selected just-inserted LOBs';
- cmp_ok try { $row->varchar_max }, 'eq', $str, 'VARCHAR(MAX) matches';
- cmp_ok try { $row->nvarchar_max }, 'eq', $str, 'NVARCHAR(MAX) matches';
- cmp_ok try { $row->varbinary_max }, 'eq', $str, 'VARBINARY(MAX) matches';
+ for my $type (qw( varchar nvarchar varbinary ) ) {
+ my $meth = "${type}_max";
+ is(
+ eval { $row->$meth },
+ $str,
+ ( uc $type ) . '(MAX) matches'
+ );
+ }
}
# test regular blobs
-try { local $^W = 0; $schema->storage->dbh->do('DROP TABLE bindtype_test') };
+eval { local $^W = 0; $schema->storage->dbh->do('DROP TABLE bindtype_test') };
$schema->storage->dbh->do(qq[
CREATE TABLE bindtype_test
(
);
diag $@ if $@;
-my $guid = try { $row->artistid }||'';
+my $guid = eval { $row->artistid }||'';
ok(($guid !~ /^{.*?}\z/), 'GUID not enclosed in braces')
or diag "GUID is: $guid";
my $row_from_db = $schema->resultset('ArtistGUID')
->search({ name => 'mtfnpy' })->first;
-is try { $row_from_db->artistid }, try { $row->artistid },
- 'PK GUID round trip (via ->search->next)';
+is(
+ eval { $row_from_db->artistid },
+ eval { $row->artistid },
+ 'PK GUID round trip (via ->search->next)'
+);
-is try { $row_from_db->a_guid }, try { $row->a_guid },
- 'NON-PK GUID round trip (via ->search->next)';
+is(
+ eval { $row_from_db->a_guid },
+ eval { $row->a_guid },
+ 'NON-PK GUID round trip (via ->search->next)'
+);
-$row_from_db = try { $schema->resultset('ArtistGUID')
- ->find($row->artistid) };
+$row_from_db = eval {
+ $schema->resultset('ArtistGUID')->find($row->artistid)
+};
-is try { $row_from_db->artistid }, try { $row->artistid },
- 'PK GUID round trip (via ->find)';
+is(
+ eval { $row_from_db->artistid },
+ eval { $row->artistid },
+ 'PK GUID round trip (via ->find)'
+);
-is try { $row_from_db->a_guid }, try { $row->a_guid },
- 'NON-PK GUID round trip (via ->find)';
+is(
+ eval { $row_from_db->a_guid },
+ eval { $row->a_guid },
+ 'NON-PK GUID round trip (via ->find)'
+);
($row_from_db) = $schema->resultset('ArtistGUID')
->search({ name => 'mtfnpy' })->all;
-is try { $row_from_db->artistid }, try { $row->artistid },
- 'PK GUID round trip (via ->search->all)';
+is(
+ eval { $row_from_db->artistid },
+ eval { $row->artistid },
+ 'PK GUID round trip (via ->search->all)'
+);
-is try { $row_from_db->a_guid }, try { $row->a_guid },
- 'NON-PK GUID round trip (via ->search->all)';
+is(
+ eval { $row_from_db->a_guid },
+ eval { $row->a_guid },
+ 'NON-PK GUID round trip (via ->search->all)'
+);
lives_ok {
$row = $schema->resultset('ArtistGUID')->create({
});
} 'created a row with explicit PK GUID';
-is try { $row->artistid }, '70171270-4822-4450-81DF-921F99BA3C06',
- 'row has correct PK GUID';
+is(
+ eval { $row->artistid },
+ '70171270-4822-4450-81DF-921F99BA3C06',
+ 'row has correct PK GUID'
+);
lives_ok {
$row->update({ artistid => '70171270-4822-4450-81DF-921F99BA3C07' });
} "updated row's PK GUID";
-is try { $row->artistid }, '70171270-4822-4450-81DF-921F99BA3C07',
- 'row has correct PK GUID';
+is(
+ eval { $row->artistid },
+ '70171270-4822-4450-81DF-921F99BA3C07',
+ 'row has correct PK GUID'
+);
lives_ok {
$row->delete;
# clean up our mess
END {
local $SIG{__WARN__} = sub {};
- if (my $dbh = try { $schema->storage->_dbh }) {
- (try { $dbh->do("DROP TABLE $_") })
+ if (my $dbh = eval { $schema->storage->_dbh }) {
+ (eval { $dbh->do("DROP TABLE $_") })
for qw/artist artist_guid varying_max_test bindtype_test/;
}
use Test::More;
use Test::Exception;
-use Try::Tiny;
use DBIx::Class::Optional::Dependencies ();
use DBIx::Class::_Util 'scope_guard';
);
diag $@ if $@;
- my $row_from_db = try { $schema->resultset('ArtistGUID')
- ->search({ name => 'mtfnpy' })->first }
- catch { diag $_ };
+ my $row_from_db;
+ lives_ok {
+ $row_from_db = $schema->resultset('ArtistGUID')->search({ name => 'mtfnpy' })->first
+ };
- is try { $row_from_db->artistid }, $row->artistid,
- 'PK GUID round trip (via ->search->next)';
+ is(
+ eval { $row_from_db->artistid },
+ $row->artistid,
+ 'PK GUID round trip (via ->search->next)'
+ );
- is try { $row_from_db->a_guid }, $row->a_guid,
- 'NON-PK GUID round trip (via ->search->next)';
+ is(
+ eval { $row_from_db->a_guid },
+ $row->a_guid,
+ 'NON-PK GUID round trip (via ->search->next)'
+ );
- $row_from_db = try { $schema->resultset('ArtistGUID')
- ->find($row->artistid) }
- catch { diag $_ };
+ lives_ok {
+ $row_from_db = $schema->resultset('ArtistGUID')->find($row->artistid)
+ };
- is try { $row_from_db->artistid }, $row->artistid,
- 'PK GUID round trip (via ->find)';
+ is(
+ eval { $row_from_db->artistid },
+ $row->artistid,
+ 'PK GUID round trip (via ->find)'
+ );
- is try { $row_from_db->a_guid }, $row->a_guid,
- 'NON-PK GUID round trip (via ->find)';
+ is(
+ eval { $row_from_db->a_guid },
+ $row->a_guid,
+ 'NON-PK GUID round trip (via ->find)'
+ );
- ($row_from_db) = try { $schema->resultset('ArtistGUID')
- ->search({ name => 'mtfnpy' })->all }
- catch { diag $_ };
+ lives_ok {
+ ($row_from_db) = $schema->resultset('ArtistGUID')->search({ name => 'mtfnpy' })->all
+ };
- is try { $row_from_db->artistid }, $row->artistid,
- 'PK GUID round trip (via ->search->all)';
+ is(
+ eval { $row_from_db->artistid },
+ $row->artistid,
+ 'PK GUID round trip (via ->search->all)'
+ );
- is try { $row_from_db->a_guid }, $row->a_guid,
- 'NON-PK GUID round trip (via ->search->all)';
+ is(
+ eval { $row_from_db->a_guid },
+ $row->a_guid,
+ 'NON-PK GUID round trip (via ->search->all)'
+ );
}
}
use DBIx::Class::Optional::Dependencies ();
use DBIx::Class::_Util 'scope_guard';
use List::Util 'shuffle';
-use Try::Tiny;
use DBICTest;
$row = $paged->next;
} 'paged query survived';
- is try { $row->artistid }, 5, 'correct row from paged query';
+ is(
+ eval { $row->artistid },
+ 5,
+ 'correct row from paged query'
+ );
# DBD bug - if any unfinished statements are present during
# DDL manipulation (test blobs below)- a segfault will occur
use Test::More;
use Test::Exception;
-use Try::Tiny;
use DBIx::Class::Optional::Dependencies ();
use DBIx::Class::_Util 'scope_guard';
title => 'my track',
});
- my $joined_track = try {
- $schema->resultset('Artist')->search({
+ my $joined_track;
+ lives_ok {
+ $joined_track = $schema->resultset('Artist')->search({
artistid => $first_artistid,
}, {
join => [{ cds => 'tracks' }],
'+select' => [ 'tracks.title' ],
'+as' => [ 'track_title' ],
})->next;
- }
- catch {
- diag "Could not execute two-step left join: $_";
- };
+ } 'Two-step left join executed';
- is try { $joined_track->get_column('track_title') }, 'my track',
- 'two-step left join works';
+ is(
+ eval { $joined_track->get_column('track_title') },
+ 'my track',
+ 'two-step left join works'
+ );
- $joined_artist = try {
- $schema->resultset('Track')->search({
+ lives_ok {
+ $joined_artist = $schema->resultset('Track')->search({
trackid => $track->trackid,
}, {
join => [{ cd => 'artist' }],
'+select' => [ 'artist.name' ],
'+as' => [ 'artist_name' ],
})->next;
- }
- catch {
- diag "Could not execute two-step inner join: $_";
- };
+ } 'Two-step inner join executed';
- is try { $joined_artist->get_column('artist_name') }, 'foo',
- 'two-step inner join works';
+ is(
+ eval { $joined_artist->get_column('artist_name') },
+ 'foo',
+ 'two-step inner join works'
+ );
# test basic transactions
$schema->txn_do(sub {
use warnings;
use Test::More;
-use Try::Tiny;
use DBIx::Class::_Util 'scope_guard';
use DBICTest;
my $guard = scope_guard { cleanup($schema) };
- try { local $^W = 0; $schema->storage->dbh->do('DROP TABLE track') };
+ eval { local $^W = 0; $schema->storage->dbh->do('DROP TABLE track') };
$schema->storage->dbh->do(<<"SQL");
CREATE TABLE track (
trackid AUTOINCREMENT PRIMARY KEY,
use Test::More;
use Test::Exception;
-use Try::Tiny;
use DBIx::Class::_Util 'scope_guard';
use DBICTest;
my $guard = scope_guard { cleanup($schema) };
# $^W because DBD::ADO is a piece of crap
- try { local $^W = 0; $schema->storage->dbh->do("DROP TABLE track") };
+ eval { local $^W = 0; $schema->storage->dbh->do("DROP TABLE track") };
$schema->storage->dbh->do(<<"SQL");
CREATE TABLE track (
trackid INT IDENTITY PRIMARY KEY,
last_updated_at DATETIME,
)
SQL
- try { local $^W = 0; $schema->storage->dbh->do("DROP TABLE event_small_dt") };
+ eval { local $^W = 0; $schema->storage->dbh->do("DROP TABLE event_small_dt") };
$schema->storage->dbh->do(<<"SQL");
CREATE TABLE event_small_dt (
id INT IDENTITY PRIMARY KEY,
small_dt SMALLDATETIME,
)
SQL
- try { local $^W = 0; $schema->storage->dbh->do("DROP TABLE event") };
+ eval { local $^W = 0; $schema->storage->dbh->do("DROP TABLE event") };
$schema->storage->dbh->do(<<"SQL");
CREATE TABLE event (
id int IDENTITY(1,1) NOT NULL,
use Test::More;
use Test::Warn;
-use Try::Tiny;
use DBICTest;
($ENV{TRAVIS_REPO_SLUG}||'') =~ m|\w+/dbix-class$|
)
) {
- require Try::Tiny;
- my $orig = \&Try::Tiny::try;
-
- # in case we loaded warnings.pm / used -w
- # ( do not do `no warnings ...` as it is also a load )
- local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /redefined/ };
-
- *Try::Tiny::try = sub (&;@) {
- my ($fr, $first_pkg) = 0;
- while( $first_pkg = caller($fr++) ) {
- last if $first_pkg !~ /^
- __ANON__
- |
- \Q(eval)\E
- $/x;
- }
-
- if ($first_pkg =~ /DBIx::Class/) {
- require Test::Builder;
- Test::Builder->new->ok(0,
- 'Using try{} within DBIC internals is a mistake - use dbic_internal_try{} instead'
- );
- }
-
- goto $orig;
- };
+ # two levels of if() because of taint mode tangling the %ENV-checks
+ # with the require() call, sigh...
+
+ if ( eval { require Try::Tiny } ) {
+ my $orig = \&Try::Tiny::try;
+
+ # in case we loaded warnings.pm / used -w
+ # ( do not do `no warnings ...` as it is also a load )
+ local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /redefined/ };
+
+ *Try::Tiny::try = sub (&;@) {
+ my ($fr, $first_pkg) = 0;
+ while( $first_pkg = caller($fr++) ) {
+ last if $first_pkg !~ /^
+ __ANON__
+ |
+ \Q(eval)\E
+ $/x;
+ }
+
+ if ($first_pkg =~ /DBIx::Class/) {
+ require Test::Builder;
+ Test::Builder->new->ok(0,
+ 'Using try{} within DBIC internals is a mistake - use dbic_internal_try{} instead'
+ );
+ }
+
+ goto $orig;
+ };
+ }
}
}
}
use Test::More;
-use Test::Exception;
-use Try::Tiny;
use File::Spec;
use DBICTest;
use DBICTest::Util 'slurp_bytes';
+use DBIx::Class::_Util 'scope_guard';
my $schema = DBICTest->init_schema();
my $exception_line_number;
# STDERR will be closed, no T::B diag in blocks
-my $exception = try {
+my $exception = do {
+ my $restore_guard = scope_guard { open(STDERR, '>&STDERRCOPY') };
close(STDERR);
- $exception_line_number = __LINE__ + 1; # important for test, do not reformat
- $schema->resultset('CD')->search({})->count;
-} catch {
- $_
-} finally {
- # restore STDERR
- open(STDERR, '>&STDERRCOPY');
+
+ eval {
+ $exception_line_number = __LINE__ + 1; # important for test, do not reformat
+ $schema->resultset('CD')->search({})->count;
+ };
+
+ my $err = $@;
};
ok $exception =~ /
/xms
or diag "Unexpected exception text:\n\n$exception\n";
+
my @warnings;
-$exception = try {
+$exception = do {
local $SIG{__WARN__} = sub { push @warnings, @_ if $_[0] =~ /character/i };
+ my $restore_guard = scope_guard { close STDERR; open(STDERR, '>&STDERRCOPY') };
close STDERR;
- open(STDERR, '>', File::Spec->devnull) or die $!;
- $schema->resultset('CD')->search({ title => "\x{1f4a9}" })->count;
- '';
-} catch {
- $_;
-} finally {
- # restore STDERR
- close STDERR;
- open(STDERR, '>&STDERRCOPY');
+
+ eval {
+ open(STDERR, '>', File::Spec->devnull) or die $!;
+ $schema->resultset('CD')->search({ title => "\x{1f4a9}" })->count;
+ };
+
+ my $err = $@;
};
die "How did that fail... $exception"
use strict;
use warnings;
use Test::More;
-use Try::Tiny;
use DBICTest;
use DBIx::Class::_Util 'dump_value';
my $schema;
- my $sql_maker = try {
+ my $sql_maker = eval {
$schema = DBICTest::Schema->connect($dsn, $user, $pass, {
quote_names => 1
});
# the SQLT producer has no idea what quotes are :/
! grep { $db eq $_ } qw( SYBASE DB2 )
and
- my $ddl = try { $schema->deployment_statements }
+ my $ddl = eval { $schema->deployment_statements }
) {
my $quoted_artist = $sql_maker->_quote('artist');
}
# some common import names (these should never ever be methods)
- for my $f (qw/carp carp_once carp_unique croak confess cluck try catch finally/) {
+ for my $f (qw(
+ carp carp_once carp_unique croak confess cluck
+ try catch finally dbic_internal_try dbic_internal_catch
+ )) {
if ($mod->can($f)) {
my $via;
for (reverse @{mro::get_linear_isa($mod)} ) {
Carp
namespace::clean
- Try::Tiny
Sub::Name
Sub::Defer
Sub::Quote