From: Peter Rabbitson Date: Wed, 17 Sep 2014 17:36:45 +0000 (+0200) Subject: Properly implement very sloppy and lazy hack from bad0b73b X-Git-Tag: v0.082800~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=777738d07cfd6055a4f40b944a69329c6995df9a;p=dbsrgits%2FDBIx-Class.git Properly implement very sloppy and lazy hack from bad0b73b 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! --- diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index c4d1111..56adec8 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -546,7 +546,12 @@ sub related_resultset { # 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; diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 22ab02b..de51b5e 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -1331,7 +1331,6 @@ sub add_relationship { my %rels = %{ $self->_relationships }; $rels{$rel} = { class => $f_source_name, source => $f_source_name, - _original_name => $rel, cond => $cond, attrs => $attrs }; $self->_relationships(\%rels); @@ -1875,7 +1874,7 @@ sub _resolve_relationship_condition { # 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};