]> Dogcows Code - chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate/blobdiff - lib/DBIx/Class/ResultSet/RecursiveUpdate.pm
test case for might_have and another minor bug fix
[chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate] / lib / DBIx / Class / ResultSet / RecursiveUpdate.pm
index cf70e397a1e0fd678891ca463566f28d02e26d87..ce89f3863cb7ed45f8a5ccdb4065f71bd18ba92b 100644 (file)
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 package DBIx::Class::ResultSet::RecursiveUpdate;
 
-our $VERSION = '0.011';
+our $VERSION = '0.012';
 
 use base qw(DBIx::Class::ResultSet);
 
@@ -107,8 +107,7 @@ sub recursive_update {
 # don't allow insert to recurse to related objects - we do the recursion ourselves
 #    $object->{_rel_in_storage} = 1;
 
-    $object->update_or_insert;
-
+    $object->update_or_insert if $object->is_changed;
 
     # updating many_to_many
     for my $name ( keys %$updates ) {
@@ -131,7 +130,7 @@ sub recursive_update {
             }
             for my $elem ( @updates ) {
                 if ( ref $elem ) {
-                    push @rows, $result_source->resultset->find($elem);
+                    push @rows, recursive_update( resultset => $result_source->resultset, updates => $elem );
                 }
                 else {
                     push @rows,
@@ -208,15 +207,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'));
     }
 }
 
This page took 0.019696 seconds and 4 git commands to generate.