[open-ils-commits] r19057 - tags/rel_1_6_2_0/Open-ILS/src/sql/Pg (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Dec 23 01:11:03 EST 2010
Author: miker
Date: 2010-12-23 01:10:59 -0500 (Thu, 23 Dec 2010)
New Revision: 19057
Modified:
tags/rel_1_6_2_0/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql
Log:
correcting upgrade script for recent vandelay.replace_field improvements
Modified: tags/rel_1_6_2_0/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql
===================================================================
--- tags/rel_1_6_2_0/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql 2010-12-23 06:10:26 UTC (rev 19056)
+++ tags/rel_1_6_2_0/Open-ILS/src/sql/Pg/1.6.1-1.6.2-upgrade-db.sql 2010-12-23 06:10:59 UTC (rev 19057)
@@ -208,18 +208,27 @@
DECLARE
xml_output TEXT;
parsed_target TEXT;
+ curr_field TEXT;
BEGIN
- parsed_target := vandelay.strip_field( target_xml, ''); -- this dance normalized the format of the xml for the IF below
- xml_output := vandelay.strip_field( parsed_target, field);
- IF xml_output <> parsed_target AND field ~ E'~' THEN
- -- we removed something, and there was a regexp restriction in the field definition, so proceed
- xml_output := vandelay.add_field( xml_output, source_xml, field, 1 );
- ELSIF field !~ E'~' THEN
- -- No regexp restriction, add the field
- xml_output := vandelay.add_field( xml_output, source_xml, field, 0 );
- END IF;
+ parsed_target := vandelay.strip_field( target_xml, ''); -- this dance normalizes the format of the xml for the IF below
+ FOR curr_field IN SELECT UNNEST( STRING_TO_ARRAY(field, ',') ) LOOP -- naive split, but it's the same we use in the perl
+
+ xml_output := vandelay.strip_field( parsed_target, curr_field);
+
+ IF xml_output <> parsed_target AND curr_field ~ E'~' THEN
+ -- we removed something, and there was a regexp restriction in the curr_field definition, so proceed
+ xml_output := vandelay.add_field( xml_output, source_xml, curr_field, 1 );
+ ELSIF curr_field !~ E'~' THEN
+ -- No regexp restriction, add the curr_field
+ xml_output := vandelay.add_field( xml_output, source_xml, curr_field, 0 );
+ END IF;
+
+ parsed_target := xml_output; -- in prep for any following loop iterations
+
+ END LOOP;
+
RETURN xml_output;
END;
$_$ LANGUAGE PLPGSQL;
More information about the open-ils-commits
mailing list