return $self->{_relationship_data}{$rel};
} else {
my $cond = $self->result_source->_resolve_condition(
- $rel_info->{cond}, $rel, $self
+ $rel_info->{cond}, $rel, $self, $rel
);
if ($rel_info->{attrs}->{undef_on_null_fk}){
return undef unless ref($cond) eq 'HASH';
# additional condition in order to avoid an unecessary join if
# that is at all possible.
my ($cond, $extended_cond) = try {
- $source->_resolve_condition( $rel_info->{cond}, $rel, $self )
+ $source->_resolve_condition( $rel_info->{cond}, $rel, $self, $rel )
}
catch {
if ($self->in_storage) {
# _resolve_condition might return two hashrefs, specially in the
# current case, since we know $f_object is an object.
my ($condref1, $condref2) = $self->result_source->_resolve_condition
- ($rel_info->{cond}, $f_obj, $rel);
+ ($rel_info->{cond}, $f_obj, $rel, $rel);
# if we get two condrefs, we need to use the second, otherwise we
# use the first.
my $link_cond;
if (ref $cond eq 'CODE') {
my ($cond_should_join, $cond_optimized) = $rel_source->_resolve_condition
- ($cond, $obj, $f_rel);
+ ($cond, $obj, $f_rel, $f_rel);
if ($cond_optimized) {
$link_cond = $cond_optimized;
} else {
next if $keyref eq 'ARRAY'; # has_many for multi_create
my $rel_q = $rsrc->_resolve_condition(
- $relinfo->{cond}, $val, $key
+ $relinfo->{cond}, $val, $key, $key
);
die "Can't handle complex relationship conditions in find" if ref($rel_q) ne 'HASH';
@related{keys %$rel_q} = values %$rel_q;
$reverse_relinfo->{cond},
$self,
$result,
+ $rel,
);
delete $data->[$index]->{$rel};
$rels->{$rel}{cond},
$child,
$main_row,
+ $rel,
);
my @rows_to_add = ref $item->{$rel} eq 'ARRAY' ? @{$item->{$rel}} : ($item->{$rel});
-alias => $as,
-relation_chain_depth => $seen->{-relation_chain_depth} || 0,
},
- $self->_resolve_condition($rel_info->{cond}, $as, $alias, $join) ];
+ $self->_resolve_condition($rel_info->{cond}, $as, $alias, $join)
+ ];
}
}
our $UNRESOLVABLE_CONDITION = \ '1 = 0';
sub _resolve_condition {
- my ($self, $cond, $as, $for, $rel) = @_;
+ my ($self, $cond, $as, $for, $relname) = @_;
if (ref $cond eq 'CODE') {
my $obj_rel = !!ref $for;
self_alias => $obj_rel ? $as : $for,
foreign_alias => $obj_rel ? 'me' : $as,
self_resultsource => $self,
- foreign_relname => $rel || ($obj_rel ? $as : $for),
+ foreign_relname => $relname || ($obj_rel ? $as : $for),
self_rowobj => $obj_rel ? $for : undef
});
}
return \%ret;
} elsif (ref $cond eq 'ARRAY') {
- return [ map { $self->_resolve_condition($_, $as, $for) } @$cond ];
+ return [ map { $self->_resolve_condition($_, $as, $for, $relname) } @$cond ];
} else {
$self->throw_exception ("Can't handle condition $cond yet :(");
}
next unless $rel_info->{attrs}{cascade_copy};
my $resolved = $self->result_source->_resolve_condition(
- $rel_info->{cond}, $rel, $new
+ $rel_info->{cond}, $rel, $new, $rel
);
my $copied = $rels_copied->{ $rel_info->{source} } ||= {};