throw error when doing parameterized join twice on same relation
Robert Sedlacek [Wed, 30 Sep 2015 17:36:21 +0000 (17:36 +0000)]
lib/DBIx/Class/ResultSet/ParameterizedJoinHack.pm
t/00basic.t

index 25c7483..53a04b0 100644 (file)
@@ -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,
index 8b0e9bc..8b58399 100644 (file)
@@ -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 {