From f1170755a54cfeb7f55d394989ebbb5c14d9cc85 Mon Sep 17 00:00:00 2001 From: berick Date: Tue, 3 May 2011 14:42:09 -0400 Subject: [PATCH] delete match_set_point's starting with leaf nodes to avoid foreign key constraints on nodes w/ children --- Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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); -- 2.11.0