From: scottmk Date: Tue, 30 Jun 2009 14:25:00 +0000 (+0000) Subject: In usr_merge(): when merging rows from reporter.*_folder, X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=65357bca304e414d32db0211c9668548091a5c3f;p=evergreen%2Fbjwebb.git In usr_merge(): when merging rows from reporter.*_folder, change the name in order to avoid collisions with existing rows belonging to the destination user. git-svn-id: svn://svn.open-ils.org/ILS/trunk@13490 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql index e0a238d7a..86abc32b5 100644 --- a/Open-ILS/src/sql/Pg/999.functions.global.sql +++ b/Open-ILS/src/sql/Pg/999.functions.global.sql @@ -50,6 +50,7 @@ DECLARE bucket_row RECORD; picklist_row RECORD; queue_row RECORD; + folder_row RECORD; BEGIN -- do some initial cleanup @@ -280,17 +281,71 @@ BEGIN -- do nothing END; BEGIN - PERFORM actor.usr_merge_rows('reporter.template_folder', 'owner', src_usr, dest_usr); + -- transfer folders the same way we transfer buckets (see above) + FOR folder_row in + SELECT id, name + FROM reporter.template_folder + WHERE owner = src_usr + LOOP + suffix := ' (' || src_usr || ')'; + LOOP + BEGIN + UPDATE reporter.template_folder + SET owner = dest_usr, name = name || suffix + WHERE id = folder_row.id; + EXCEPTION WHEN unique_violation THEN + suffix := suffix || ' '; + CONTINUE; + END; + EXIT; + END LOOP; + END LOOP; EXCEPTION WHEN undefined_table THEN -- do nothing END; BEGIN - PERFORM actor.usr_merge_rows('reporter.report_folder', 'owner', src_usr, dest_usr); + -- transfer folders the same way we transfer buckets (see above) + FOR folder_row in + SELECT id, name + FROM reporter.report_folder + WHERE owner = src_usr + LOOP + suffix := ' (' || src_usr || ')'; + LOOP + BEGIN + UPDATE reporter.report_folder + SET owner = dest_usr, name = name || suffix + WHERE id = folder_row.id; + EXCEPTION WHEN unique_violation THEN + suffix := suffix || ' '; + CONTINUE; + END; + EXIT; + END LOOP; + END LOOP; EXCEPTION WHEN undefined_table THEN -- do nothing END; BEGIN - PERFORM actor.usr_merge_rows('reporter.output_folder', 'owner', src_usr, dest_usr); + -- transfer folders the same way we transfer buckets (see above) + FOR folder_row in + SELECT id, name + FROM reporter.output_folder + WHERE owner = src_usr + LOOP + suffix := ' (' || src_usr || ')'; + LOOP + BEGIN + UPDATE reporter.output_folder + SET owner = dest_usr, name = name || suffix + WHERE id = folder_row.id; + EXCEPTION WHEN unique_violation THEN + suffix := suffix || ' '; + CONTINUE; + END; + EXIT; + END LOOP; + END LOOP; EXCEPTION WHEN undefined_table THEN -- do nothing END;