[open-ils-commits] r13490 - trunk/Open-ILS/src/sql/Pg (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jun 30 10:25:02 EDT 2009
Author: scottmk
Date: 2009-06-30 10:25:00 -0400 (Tue, 30 Jun 2009)
New Revision: 13490
Modified:
trunk/Open-ILS/src/sql/Pg/999.functions.global.sql
Log:
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.
Modified: trunk/Open-ILS/src/sql/Pg/999.functions.global.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/999.functions.global.sql 2009-06-30 13:06:20 UTC (rev 13489)
+++ trunk/Open-ILS/src/sql/Pg/999.functions.global.sql 2009-06-30 14:25:00 UTC (rev 13490)
@@ -50,6 +50,7 @@
bucket_row RECORD;
picklist_row RECORD;
queue_row RECORD;
+ folder_row RECORD;
BEGIN
-- do some initial cleanup
@@ -280,17 +281,71 @@
-- 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;
More information about the open-ils-commits
mailing list