only limit resultset if there are related rows left
authorAlexander Hartmaier <alexander.hartmaier@t-systems.at>
Mon, 11 Oct 2010 14:29:08 +0000 (16:29 +0200)
committerAlexander Hartmaier <alexander.hartmaier@t-systems.at>
Mon, 11 Oct 2010 14:29:08 +0000 (16:29 +0200)
lib/DBIx/Class/ResultSet/RecursiveUpdate.pm

index 2d3efb8dfd19a60157ec56d86bc6876749384389..c0be5cdd27a82ec2e0eeb8d7be061a547a1cb67f 100644 (file)
@@ -299,7 +299,6 @@ sub _update_relation {
 
         #warn "\tcreated and updated related rows\n";
 
-        my @cond;
         my @related_pks = $related_resultset->result_source->primary_columns;
 
         my $rs_rel_delist = $object->$name;
@@ -315,6 +314,7 @@ sub _update_relation {
 
         # foreign table has multiple pk columns
         else {
+            my @cond;
             for my $obj (@updated_objs) {
                 my %cond_for_obj;
                 for my $col (@related_pks) {
@@ -322,7 +322,10 @@ sub _update_relation {
                 }
                 push @cond, \%cond_for_obj;
             }
-            $rs_rel_delist = $rs_rel_delist->search_rs( { -not => [@cond] } );
+            # only limit resultset if there are related rows left
+            if (scalar @cond) {
+                $rs_rel_delist = $rs_rel_delist->search_rs( { -not => [@cond] } );
+            }
         }
 
         #warn "\tCOND: " . Dumper(\%cond);
This page took 0.021928 seconds and 4 git commands to generate.