X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FHasMany.pm;h=6bdefd472eaf27b2521da14b754b84d73774340a;hb=bc96f2606c021439a25e1376db53fe418cf4bb49;hp=eeead265c07be9ac00cb0f698bbb161fa5c9a3f9;hpb=303cf522b1c2841ecab3056cfbb4314fa05151a2;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/Relationship/HasMany.pm b/lib/DBIx/Class/Relationship/HasMany.pm index eeead26..6bdefd4 100644 --- a/lib/DBIx/Class/Relationship/HasMany.pm +++ b/lib/DBIx/Class/Relationship/HasMany.pm @@ -7,13 +7,19 @@ use warnings; sub has_many { my ($class, $rel, $f_class, $cond, $attrs) = @_; - $class->ensure_class_loaded($f_class); - unless (ref $cond) { + $class->ensure_class_loaded($f_class); my ($pri, $too_many) = $class->primary_columns; - $class->throw_exception( "has_many can only infer join for a single ". - "primary key; ${class} has more" ) - if $too_many; + + $class->throw_exception( + "has_many can only infer join for a single primary key; ". + "${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) {