1 package DBIx::Class::Relationship::HasMany;
7 my ($class, $rel, $f_class, $cond, $attrs) = @_;
9 eval "require $f_class";
13 if (defined $cond && length $cond) {
15 $class->throw( "No such column ${f_key} on foreign class ${f_class}" )
16 unless ($@ || $f_class->_columns->{$f_key});
18 $class =~ /([^\:]+)$/;
19 $f_key = lc $1 if $f_class->_columns->{lc $1};
20 $class->throw( "Unable to resolve foreign key for has_many from ${class} to ${f_class}" )
23 my ($pri, $too_many) = keys %{ $class->_primaries };
24 $class->throw( "has_many can only infer join for a single primary key; ${class} has more" )
26 $cond = { "foreign.${f_key}" => "self.${pri}" },
29 $class->add_relationship($rel, $f_class, $cond,
30 { accessor => 'multi',