1 package # hide from PAUSE
2 DBIx::Class::Relationship::HasMany;
8 my ($class, $rel, $f_class, $cond, $attrs) = @_;
11 $class->ensure_class_loaded($f_class);
12 my ($pri, $too_many) = $class->primary_columns;
14 $class->throw_exception(
15 "has_many can only infer join for a single primary key; ".
20 if (defined $cond && length $cond) {
22 $guess = "caller specified foreign key '$f_key'";
24 $class =~ /([^\:]+)$/;
25 $f_key = lc $1; # go ahead and guess; best we can do
26 $guess = "using our class name '$class' as foreign key";
29 my $f_class_loaded = eval { $f_class->columns };
30 $class->throw_exception(
31 "No such column ${f_key} on foreign class ${f_class} ($guess)"
32 ) if $f_class_loaded && !$f_class->has_column($f_key);
34 $cond = { "foreign.${f_key}" => "self.${pri}" };
37 $class->add_relationship($rel, $f_class, $cond, {