[open-ils-commits] r13484 - trunk/Open-ILS/src/sql/Pg (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Jun 29 19:03:49 EDT 2009
Author: scottmk
Date: 2009-06-29 19:03:48 -0400 (Mon, 29 Jun 2009)
New Revision: 13484
Modified:
trunk/Open-ILS/src/sql/Pg/999.functions.global.sql
Log:
In actor.usr_merge(): transfer picklists with changes of the
name column so as to avoid collisions with existing picklists.
Modified: trunk/Open-ILS/src/sql/Pg/999.functions.global.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/999.functions.global.sql 2009-06-29 21:14:29 UTC (rev 13483)
+++ trunk/Open-ILS/src/sql/Pg/999.functions.global.sql 2009-06-29 23:03:48 UTC (rev 13484)
@@ -48,6 +48,7 @@
DECLARE
suffix TEXT;
bucket_row RECORD;
+ picklist_row RECORD;
BEGIN
-- do some initial cleanup
@@ -201,7 +202,27 @@
-- 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;
More information about the open-ils-commits
mailing list