From: John Napiorkowski Date: Fri, 2 Apr 2010 16:35:01 +0000 (-0400) Subject: skip trying to create a might_have relationship if there is no data to insert X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-DBIx-Class-ResultSet-RecursiveUpdate;a=commitdiff_plain;h=43f13ea3f94336cf179ed33be4f1568b9c69a8a5 skip trying to create a might_have relationship if there is no data to insert --- diff --git a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm index 1af66cc..eeec84c 100644 --- a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm +++ b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm @@ -208,15 +208,17 @@ sub _update_relation { object => $object->$name ); } - else{ + else{ $sub_object = recursive_update( resultset => $related_result, updates => $sub_updates, resolved => $resolved ); } } elsif( ! ref $sub_updates ){ - $sub_object = $related_result->find( $sub_updates ); + $sub_object = $related_result->find( $sub_updates ) + unless (!$sub_updates && ($info->{attrs}{join_type} eq 'LEFT')); } - $object->set_from_related( $name, $sub_object ); + $object->set_from_related( $name, $sub_object ) + unless (!$sub_object && !$sub_updates && ($info->{attrs}{join_type} eq 'LEFT')); } }