[open-ils-commits] r18961 - in branches/rel_1_6/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Dec 10 09:33:44 EST 2010
Author: miker
Date: 2010-12-10 09:33:42 -0500 (Fri, 10 Dec 2010)
New Revision: 18961
Added:
branches/rel_1_6/Open-ILS/src/sql/Pg/upgrade/0469.schema.authority-maint-trigger-funcs.sql
Modified:
branches/rel_1_6/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
Log:
partial backport of r18957 to capture the fixes for vandelay.replace_field -- specifically, normalizing the XML for comparison when deciding if the "add" side of a replace should proceed
Modified: branches/rel_1_6/Open-ILS/src/sql/Pg/012.schema.vandelay.sql
===================================================================
--- branches/rel_1_6/Open-ILS/src/sql/Pg/012.schema.vandelay.sql 2010-12-10 14:27:37 UTC (rev 18960)
+++ branches/rel_1_6/Open-ILS/src/sql/Pg/012.schema.vandelay.sql 2010-12-10 14:33:42 UTC (rev 18961)
@@ -268,10 +268,12 @@
CREATE OR REPLACE FUNCTION vandelay.replace_field ( target_xml TEXT, source_xml TEXT, field TEXT ) RETURNS TEXT AS $_$
DECLARE
xml_output TEXT;
+ parsed_target TEXT;
BEGIN
- xml_output := vandelay.strip_field( target_xml, field);
+ 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 <> target_xml AND field ~ E'~' THEN
+ 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
Copied: branches/rel_1_6/Open-ILS/src/sql/Pg/upgrade/0469.schema.authority-maint-trigger-funcs.sql (from rev 18957, trunk/Open-ILS/src/sql/Pg/upgrade/0469.schema.authority-maint-trigger-funcs.sql)
===================================================================
--- branches/rel_1_6/Open-ILS/src/sql/Pg/upgrade/0469.schema.authority-maint-trigger-funcs.sql (rev 0)
+++ branches/rel_1_6/Open-ILS/src/sql/Pg/upgrade/0469.schema.authority-maint-trigger-funcs.sql 2010-12-10 14:33:42 UTC (rev 18961)
@@ -0,0 +1,26 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0469'); -- miker
+
+CREATE OR REPLACE FUNCTION vandelay.replace_field ( target_xml TEXT, source_xml TEXT, field TEXT ) RETURNS TEXT AS $_$
+DECLARE
+ xml_output TEXT;
+ parsed_target 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;
+
+ RETURN xml_output;
+END;
+$_$ LANGUAGE PLPGSQL;
+
+COMMIT;
+
More information about the open-ils-commits
mailing list