merging 564:565 from resultset branch to trunk for lib/DBIx/Class/Relationship/Belong...
Brandon L. Black [Tue, 24 Jan 2006 18:36:23 +0000 (18:36 +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 {