use filter accessor on single-column explicit join condition hashes
Brandon L. Black [Tue, 24 Jan 2006 18:30:54 +0000 (18:30 +0000)]
lib/DBIx/Class/Relationship/BelongsTo.pm

index b1ef52a..326a99a 100644 (file)
@@ -45,9 +45,10 @@ sub belongs_to {
       }
       $cond_rel->{"foreign.$_"} = "self.".$cond->{$_};
     }
+    my $acc_type = (scalar keys %$cond_rel == 1) ? 'filter' : 'single';
     $class->add_relationship($rel, $f_class,
       $cond_rel,
-      { accessor => 'single', %{$attrs || {}} }
+      { accessor => $acc_type, %{$attrs || {}} }
     );
   }
   else {