From: Peter Rabbitson Date: Tue, 27 Sep 2016 17:49:19 +0000 (+0200) Subject: Simplify guarded pass-through added to CDBI in ee333775 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eab44f5277e5f7f479528b80beba4c306e75af54;p=dbsrgits%2FDBIx-Class.git Simplify guarded pass-through added to CDBI in ee333775 --- diff --git a/lib/DBIx/Class/CDBICompat/Relationships.pm b/lib/DBIx/Class/CDBICompat/Relationships.pm index f3c0c9c..7b08d07 100644 --- a/lib/DBIx/Class/CDBICompat/Relationships.pm +++ b/lib/DBIx/Class/CDBICompat/Relationships.pm @@ -218,7 +218,10 @@ sub search { } sub new_related { - return shift->search_related(shift)->new_result(@_); + $_[0]->throw_exception("Calling new_related() as a class method is not supported") + unless length ref $_[0]; + + shift->next::method(@_); } =head1 FURTHER QUESTIONS? diff --git a/t/cdbi/09-has_many.t b/t/cdbi/09-has_many.t index c063657..bac11ed 100644 --- a/t/cdbi/09-has_many.t +++ b/t/cdbi/09-has_many.t @@ -50,7 +50,7 @@ eval { my $pj = Film->add_to_actors(\%pj_data) }; like $@, qr/class/, "add_to_actors must be object method"; eval { my $pj = $btaste->add_to_actors(%pj_data) }; -like $@, qr/Result object instantiation requires a single hashref argument/, "add_to_actors takes hash"; +like $@, qr/Result object instantiation requires a hashref as argument/, "add_to_actors takes hash"; ok( my $pj = $btaste->add_to_actors(