From: Peter Rabbitson Date: Fri, 24 Oct 2014 23:35:14 +0000 (+0200) Subject: Fix endless loop on BareSourcelessResultClass->throw_exception(...) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4f52479b;p=dbsrgits%2FDBIx-Class-Historic.git Fix endless loop on BareSourcelessResultClass->throw_exception(...) There is a better fix for this in the pipes, but this will do for now --- diff --git a/Changes b/Changes index c663be3..7918191 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Revision history for DBIx::Class * Fixes - Fix incorrect collapsing-parser source being generated in the presence of unicode data among the collapse-points + - Fix endless loop on BareSourcelessResultClass->throw_exception(...) * Misc - Depend on newer Moo, fixing some interoperability issues: diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index 45ade30..222817a 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -1564,8 +1564,8 @@ See L. sub throw_exception { my $self=shift; - if (ref $self && ref $self->result_source ) { - $self->result_source->throw_exception(@_) + if (ref $self && ref (my $rsrc = try { $self->result_source_instance } ) ) { + $rsrc->throw_exception(@_) } else { DBIx::Class::Exception->throw(@_); diff --git a/t/60core.t b/t/60core.t index f92159b..9ee9b6d 100644 --- a/t/60core.t +++ b/t/60core.t @@ -636,4 +636,6 @@ SKIP: { throws_ok { $schema->resultset} qr/resultset\(\) expects a source name/, 'resultset with no argument throws exception'; +throws_ok { $schema->source('Artist')->result_class->new( 'bugger' ) } qr/must be a hashref/; + done_testing; diff --git a/t/resultsource/bare_resultclass_exception.t b/t/resultsource/bare_resultclass_exception.t new file mode 100644 index 0000000..6b8d72c --- /dev/null +++ b/t/resultsource/bare_resultclass_exception.t @@ -0,0 +1,17 @@ +use strict; +use warnings; + +use Test::More; +use Test::Exception; + +use lib 't/lib'; +use DBICTest; + +{ + package DBICTest::Foo; + use base "DBIx::Class::Core"; +} + +throws_ok { DBICTest::Foo->new("urgh") } qr/must be a hashref/; + +done_testing;