From: Robert Sedlacek Date: Wed, 30 Sep 2015 17:36:21 +0000 (+0000) Subject: throw error when doing parameterized join twice on same relation X-Git-Tag: v0.000001~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6d37bc628865d28297e5cf9060f5e21d1d9ec733;p=dbsrgits%2FDBIx-Class-ParameterizedJoinHack.git throw error when doing parameterized join twice on same relation --- diff --git a/lib/DBIx/Class/ResultSet/ParameterizedJoinHack.pm b/lib/DBIx/Class/ResultSet/ParameterizedJoinHack.pm index 25c7483..53a04b0 100644 --- a/lib/DBIx/Class/ResultSet/ParameterizedJoinHack.pm +++ b/lib/DBIx/Class/ResultSet/ParameterizedJoinHack.pm @@ -23,6 +23,9 @@ sub with_parameterized_join { unless $params_ref eq 'HASH'; } + die "Parameterized join can only be used once per relation" + if exists(($self->{attrs}{join_parameters} || {})->{$rel}); + $self->search_rs( {}, { join => $rel, diff --git a/t/00basic.t b/t/00basic.t index 8b0e9bc..8b58399 100644 --- a/t/00basic.t +++ b/t/00basic.t @@ -83,12 +83,13 @@ subtest 'has_many' => sub { }; subtest 'overrides' => sub { - is $people - ->$join_with_min(19) - ->$join_with_min(29) - ->$search - ->$fetch_count, - 1, 'overridden parameter'; + like exception { + $people + ->$join_with_min(19) + ->$join_with_min(29) + ->$search + ->$fetch_count; + }, qr{once.+per.+relation}i, 'throws error'; }; subtest 'multi parameter' => sub {