X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FHasOne.pm;h=584ed2a272b55c362270ccefb4fe39004427ef55;hb=3cbddeb1871beb9684c0a9fbf6e90146a2d16742;hp=9f821a47c314a4f518a5b6019e1317de7b2caebe;hpb=503536d5b216b4d85ed3f5420f3db93d4c033d86;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship/HasOne.pm b/lib/DBIx/Class/Relationship/HasOne.pm index 9f821a4..584ed2a 100644 --- a/lib/DBIx/Class/Relationship/HasOne.pm +++ b/lib/DBIx/Class/Relationship/HasOne.pm @@ -13,12 +13,15 @@ sub has_one { sub _has_one { my ($class, $join_type, $rel, $f_class, $cond, $attrs) = @_; - unless ($cond) { + eval "require $f_class"; + unless (ref $cond) { my ($pri, $too_many) = keys %{ $class->_primaries }; $class->throw( "might_have/has_one can only infer join for a single primary key; ${class} has more" ) if $too_many; my $f_key; - if ($f_class->_columns->{$rel}) { + if ($cond) { + $f_key = $cond; + } elsif ($f_class->_columns->{$rel}) { $f_key = $rel; } else { ($f_key, $too_many) = keys %{ $f_class->_primaries };