We are abusing local() here - might as well abuse it correctly.
This way we do not add a permanent shitty name to the relinfo structure and
nobody needs to fix their tests. Winning!
# root alias as 'me', instead of $rel (as opposed to invoking
# $rs->search_related)
- local $rsrc->{_relationships}{me} = $rsrc->{_relationships}{$rel}; # make the fake 'me' rel
+ # make the fake 'me' rel
+ local $rsrc->{_relationships}{me} = {
+ %{ $rsrc->{_relationships}{$rel} },
+ _original_name => $rel,
+ };
+
my $obj_table_alias = lc($rsrc->source_name) . '__row';
$obj_table_alias =~ s/\W+/_/g;
my %rels = %{ $self->_relationships };
$rels{$rel} = { class => $f_source_name,
source => $f_source_name,
- _original_name => $rel,
cond => $cond,
attrs => $attrs };
$self->_relationships(\%rels);
# TEMP
$exception_rel_id = "relationship '$rel_info->{_original_name}' on source '@{[ $self->source_name ]}'"
- if $rel_info;
+ if $rel_info and exists $rel_info->{_original_name};
$self->throw_exception("No practical way to resolve $exception_rel_id between two data structures")
if exists $args->{self_result_object} and exists $args->{foreign_values};