my ($self, $col, $f_class, %args) = @_;
$self->throw( "No such column ${col}" ) unless $self->_columns->{$col};
eval "require $f_class";
- if ($args{'inflate'} || $args{'deflate'}) {
+ if ($args{'inflate'} || $args{'deflate'}) { # Non-database has_a
if (!ref $args{'inflate'}) {
my $meth = $args{'inflate'};
$args{'inflate'} = sub { $f_class->$meth(shift); };
return 1;
}
my ($pri, $too_many) = keys %{ $f_class->_primaries };
- $self->throw( "has_a only works with a single primary key; ${f_class} has more" )
+ $self->throw( "has_a only works with a single primary key; ${f_class} has more. try using a belongs_to relationship instead of Class::DBI compat rels" )
if $too_many;
- $self->add_relationship($col, $f_class,
- { "foreign.${pri}" => "self.${col}" },
- { accessor => 'filter' } );
+
+ $self->belongs_to($col, $f_class);
return 1;
}