my ($class, $rel, $acc_type) = @_;
my %meth;
if ($acc_type eq 'single') {
- my $rel_cond = $class->relationship_info($rel)->{cond};
+ my $rel_info = $class->relationship_info($rel);
$meth{$rel} = sub {
my $self = shift;
if (@_) {
return $self->{_relationship_data}{$rel};
} else {
my $cond = $self->result_source->resolve_condition(
- $rel_cond, $rel, $self
+ $rel_info->{cond}, $rel, $self
);
- return if grep { not defined } values %$cond;
+ if ($rel_info->{attrs}->{undef_on_null_fk}){
+ return if grep { not defined } values %$cond;
+ }
my $val = $self->find_related($rel, {}, {});
return unless $val;
return $self->{_relationship_data}{$rel} = $val;