From: Peter Rabbitson Date: Wed, 30 Mar 2016 13:44:15 +0000 (+0200) Subject: Fix *stupid* silencing of exceptions introduced in 4e9fc3f3 X-Git-Tag: v0.082840~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0844bb396f5702db73a8eea947116475b4d89e9a;p=dbsrgits%2FDBIx-Class.git Fix *stupid* silencing of exceptions introduced in 4e9fc3f3 ( cherry-pick of b4976ee31 ) The reason this has not been detected is because it is virtually impossible for the stock inflate_result() to throw, and pretty rare for custom ones. ARGH! --- diff --git a/Changes b/Changes index 49461a7..de7fae5 100644 --- a/Changes +++ b/Changes @@ -15,6 +15,7 @@ Revision history for DBIx::Class - Fix use of ::Schema::Versioned combined with a user-supplied $dbh->{HandleError} (GH#101) - Fix parsing of DSNs containing driver arguments (GH#99) + - Fix silencing of exceptions thrown by custom inflate_result() methods - Fix spurious ROLLBACK statements when a TxnScopeGuard fails a commit of a transaction with deferred FK checks: a guard is now inactivated immediately before the commit is attempted (RT#107159) diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index a8b3471..2ca4427 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -1417,7 +1417,7 @@ sub _construct_results { : '@$rows = map { $inflator_cref->($res_class, $rsrc, { %s } ) } @$rows' ), ( join (', ', map { "\$infmap->[$_] => \$_->[$_]" } 0..$#$infmap ) ) - ); + ) . '; 1' or die; } } else { diff --git a/t/resultset/inflate_result_api.t b/t/resultset/inflate_result_api.t index e6bedc2..29daa6b 100644 --- a/t/resultset/inflate_result_api.t +++ b/t/resultset/inflate_result_api.t @@ -5,6 +5,8 @@ no warnings 'exiting'; use Test::More; use Test::Deep; use lib qw(t/lib); +use Test::Exception; + use DBICTest; my $schema = DBICTest->init_schema(no_populate => 1); @@ -502,6 +504,7 @@ sub cmp_structures { cmp_deeply($left, $right, $msg||()) or next INFTYPE; } + { package DBICTest::_DoubleResult; @@ -529,4 +532,18 @@ is_deeply( })->all_hri}) x 2 ], ); + +{ + package DBICTest::_DieTrying; + + sub inflate_result { + die "nyah nyah nyah"; + } +} + +throws_ok { + $schema->resultset('CD')->search({}, { result_class => 'DBICTest::_DieTrying' })->all +} qr/nyah nyah nyah/, 'Exception in custom inflate_result propagated correctly'; + + done_testing;