Rollback some mistaken indirect-call-elisions from e5053694
Peter Rabbitson [Sun, 15 May 2016 20:52:18 +0000 (22:52 +0200)]
The ::Realtionship::Base calls perform result-instance adjustments, thus
they CAN NOT be omitted

That would have been *really* embarrassing, good thing dependent smoking
caught this crap. Not adding an extra test at this point, but probably
should :/

Audit was performed by scrutinizing each line of:
grep -- '->' \
 <(git diff -U0 e50536940^..e50536940) \
 <(git diff -U0 77c3a5dca^..77c3a5dca) \
> argh.log

lib/DBIx/Class/Relationship/Accessor.pm
lib/DBIx/Class/Relationship/Base.pm
lib/DBIx/Class/Relationship/ProxyMethods.pm

index fae251e..0dab640 100644 (file)
@@ -100,8 +100,8 @@ EOC
   }
   elsif ($acc_type eq 'multi') {
 
-    quote_sub "${class}::${rel}_rs", "shift->related_resultset('$rel')->search_rs( \@_ )";
-    quote_sub "${class}::add_to_${rel}", "shift->related_resultset('$rel')->new_result( \@_ )->insert";
+    quote_sub "${class}::${rel}_rs", "shift->related_resultset( q{$rel} )->search_rs( \@_ )";
+    quote_sub "${class}::add_to_${rel}", "shift->create_related( q{$rel} => \@_ )";
     quote_sub "${class}::${rel}", sprintf( <<'EOC', perlstring $rel );
       DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_WANTARRAY and my $sog = DBIx::Class::_Util::fail_on_internal_wantarray;
       shift->related_resultset(%s)->search( @_ )
index 323c31e..994e7d7 100644 (file)
@@ -767,7 +767,7 @@ sub find_or_create_related {
   my $self = shift;
   my $rel = shift;
   my $obj = $self->related_resultset($rel)->find(@_);
-  return (defined($obj) ? $obj : $self->related_resultset($rel)->new_result(@_)->insert);
+  return (defined($obj) ? $obj : $self->create_related( $rel => @_ ));
 }
 
 =head2 update_or_create_related
index f7585a7..cb61514 100644 (file)
@@ -28,7 +28,7 @@ sub proxy_to_related {
     my $self = shift;
     my $relobj = $self->%1$s;
     if (@_ && !defined $relobj) {
-      $relobj = $self->related_resultset(q{%1$s})->new_result({ %2$s => $_[0] })->insert;
+      $relobj = $self->create_related( q{%1$s} => { %2$s => $_[0] } );
       @_ = ();
     }
     $relobj ? $relobj->%2$s(@_) : undef;