From: berick Date: Tue, 3 May 2011 18:42:09 +0000 (-0400) Subject: delete match_set_point's starting with leaf nodes to avoid foreign key constraints... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f1170755a54cfeb7f55d394989ebbb5c14d9cc85;p=evergreen%2Fequinox.git delete match_set_point's starting with leaf nodes to avoid foreign key constraints on nodes w/ children --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm index 1d69eb4287..0820cb0f04 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm @@ -1420,8 +1420,15 @@ sub match_set_update_tree { {"order_by" => {"vmsp" => "id DESC"}} ]) or return $e->die_event; - foreach (@$existing) { - $e->delete_vandelay_match_set_point($_) or return $e->die_event; + # delete points, working up from leaf points to the root + while(@$existing) { + for my $point (shift @$existing) { + if( grep {$_->parent eq $point->id} @$existing) { + push(@$existing, $point); + } else { + $e->delete_vandelay_match_set_point($point) or return $e->die_event; + } + } } _walk_new_vmsp($e, $match_set_id, $tree);