From: Alexander Hartmaier Date: Mon, 11 Oct 2010 14:29:08 +0000 (+0200) Subject: only limit resultset if there are related rows left X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-DBIx-Class-ResultSet-RecursiveUpdate;a=commitdiff_plain;h=ecbe0c373c166ca05e805f1a459751b5a1040577 only limit resultset if there are related rows left --- diff --git a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm index 2d3efb8..c0be5cd 100644 --- a/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm +++ b/lib/DBIx/Class/ResultSet/RecursiveUpdate.pm @@ -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);