X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FHasOne.pm;h=4c910b8c667bc82e19c2404820fa0df663b0e114;hb=0e4fb877c0d647259a7b7f1f38f9dbe65b31cf6b;hp=568078ce3c503a93536ead74b311342741019fa1;hpb=fd4df97578076cdb1a82385b21995ed28637e096;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship/HasOne.pm b/lib/DBIx/Class/Relationship/HasOne.pm index 568078c..4c910b8 100644 --- a/lib/DBIx/Class/Relationship/HasOne.pm +++ b/lib/DBIx/Class/Relationship/HasOne.pm @@ -4,6 +4,11 @@ package # hide from PAUSE use strict; use warnings; +our %_pod_inherit_config = + ( + class_map => { 'DBIx::Class::Relationship::HasOne' => 'DBIx::Class::Relationship' } + ); + sub might_have { shift->_has_one('LEFT' => @_); } @@ -17,10 +22,17 @@ sub _has_one { unless (ref $cond) { $class->ensure_class_loaded($f_class); my ($pri, $too_many) = $class->primary_columns; + $class->throw_exception( "might_have/has_one can only infer join for a single primary key; ". "${class} has more" ) if $too_many; + + $class->throw_exception( + "might_have/has_one needs a primary key to infer a join; ". + "${class} has none" + ) if !defined $pri && (!defined $cond || !length $cond); + my $f_class_loaded = eval { $f_class->columns }; my ($f_key,$guess); if (defined $cond && length $cond) {