From 1b4390317190bb0a2c294477b06d2109e168639e Mon Sep 17 00:00:00 2001 From: scottmk Date: Mon, 29 Jun 2009 23:03:48 +0000 Subject: [PATCH] In actor.usr_merge(): transfer picklists with changes of the name column so as to avoid collisions with existing picklists. git-svn-id: svn://svn.open-ils.org/ILS/trunk@13484 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/999.functions.global.sql | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/sql/Pg/999.functions.global.sql b/Open-ILS/src/sql/Pg/999.functions.global.sql index b26245361..f0b8a5928 100644 --- a/Open-ILS/src/sql/Pg/999.functions.global.sql +++ b/Open-ILS/src/sql/Pg/999.functions.global.sql @@ -48,6 +48,7 @@ CREATE OR REPLACE FUNCTION actor.usr_merge( src_usr INT, dest_usr INT, del_addrs DECLARE suffix TEXT; bucket_row RECORD; + picklist_row RECORD; BEGIN -- do some initial cleanup @@ -201,7 +202,27 @@ BEGIN -- acq.* UPDATE acq.fund_allocation SET allocator = dest_usr WHERE allocator = src_usr; - PERFORM actor.usr_merge_rows('acq.picklist', 'owner', src_usr, dest_usr); + + -- transfer picklists the same way we transfer buckets (see above) + FOR picklist_row in + SELECT id, name + FROM acq.picklist + WHERE owner = src_usr + LOOP + suffix := ' (' || src_usr || ')'; + LOOP + BEGIN + UPDATE acq.picklist + SET owner = dest_usr, name = name || suffix + WHERE id = picklist_row.id; + EXCEPTION WHEN unique_violation THEN + suffix := suffix || ' '; + CONTINUE; + END; + EXIT; + END LOOP; + END LOOP; + UPDATE acq.purchase_order SET owner = dest_usr WHERE owner = src_usr; UPDATE acq.po_note SET creator = dest_usr WHERE creator = src_usr; UPDATE acq.po_note SET editor = dest_usr WHERE editor = src_usr; -- 2.11.0