X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FHasMany.pm;h=d74a9a4abcee236911b45e0ce4c489b78e1301ce;hb=9f0c231fcab6598822d36c8de64ed7a19f0d6b5c;hp=2c9a3bb723178eb60f7afc1ec92a08ec5cc24177;hpb=fd4df97578076cdb1a82385b21995ed28637e096;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship/HasMany.pm b/lib/DBIx/Class/Relationship/HasMany.pm index 2c9a3bb..d74a9a4 100644 --- a/lib/DBIx/Class/Relationship/HasMany.pm +++ b/lib/DBIx/Class/Relationship/HasMany.pm @@ -4,6 +4,11 @@ package # hide from PAUSE use strict; use warnings; +our %_pod_inherit_config = + ( + class_map => { 'DBIx::Class::Relationship::HasMany' => 'DBIx::Class::Relationship' } + ); + sub has_many { my ($class, $rel, $f_class, $cond, $attrs) = @_; @@ -16,6 +21,11 @@ sub has_many { "${class} has more" ) if $too_many; + $class->throw_exception( + "has_many needs a primary key to infer a join; ". + "${class} has none" + ) if !defined $pri && (!defined $cond || !length $cond); + my ($f_key,$guess); if (defined $cond && length $cond) { $f_key = $cond; @@ -30,7 +40,7 @@ sub has_many { $class->throw_exception( "No such column ${f_key} on foreign class ${f_class} ($guess)" ) if $f_class_loaded && !$f_class->has_column($f_key); - + $cond = { "foreign.${f_key}" => "self.${pri}" }; }