use filter accessor on single-column explicit join condition hashes
[dbsrgits/DBIx-Class.git] / 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 {