From: Peter Rabbitson Date: Wed, 1 Dec 2010 02:21:50 +0000 (+0100) Subject: Limit the void context search exceptions to non-dbic code X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0959ba52e25db43fcd4fe83c2b49ad017d978fd0;p=dbsrgits%2FDBIx-Class-Historic.git Limit the void context search exceptions to non-dbic code i can fully imagine someone doing it because of side-effects they've added to something they didn't realize called search --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 02cee66..427657a 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -278,7 +278,15 @@ sub search { return $rs; } else { - $self->throw_exception ('->search is *not* a mutator, calling it in void context makes no sense'); + # we can be called by a relationship helper, which in + # turn may be called in void context due to some braindead + # overload or whatever else the user decided to be clever + # at this particular day. Thus limit the exception to + # external code calls only + $self->throw_exception ('->search is *not* a mutator, calling it in void context makes no sense') + if (caller)[0] !~ /^\QDBIx::Class::/; + + return (); } }