Properly implement very sloppy and lazy hack from bad0b73b
Peter Rabbitson [Wed, 17 Sep 2014 17:36:45 +0000 (19:36 +0200)]
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!

lib/DBIx/Class/Relationship/Base.pm
lib/DBIx/Class/ResultSource.pm

index c4d1111..56adec8 100644 (file)
@@ -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;
 
index 22ab02b..de51b5e 100644 (file)
@@ -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};