From 43f13ea3f94336cf179ed33be4f1568b9c69a8a5 Mon Sep 17 00:00:00 2001 From: John Napiorkowski Date: Fri, 2 Apr 2010 12:35:01 -0400 Subject: [PATCH] skip trying to create a might_have relationship if there is no data to insert --- lib/DBIx/Class/ResultSet/RecursiveUpdate.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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')); } } -- 2.45.2