[GIT] Evergreen ILS branch rel_3_14 updated. b84d35901e29ce0be1a2c1bd9c02785004cf421c

This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Evergreen ILS". The branch, rel_3_14 has been updated via b84d35901e29ce0be1a2c1bd9c02785004cf421c (commit) via 5d11af8a28317a5d202c5610f95f8c2f47e27266 (commit) via 7782796ba49a419ae03787d39ac396c4ceba87e5 (commit) from f54b1a9e1844d03d27cc6f60f04b9981eb648374 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b84d35901e29ce0be1a2c1bd9c02785004cf421c Author: Mike Rylander <mrylander@gmail.com> Date: Wed Jun 4 10:11:04 2025 -0400 Stamping upgrade script Signed-off-by: Mike Rylander <mrylander@gmail.com> diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 544d0fa61a..0b22ef1a4d 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -92,7 +92,7 @@ CREATE TRIGGER no_overlapping_deps BEFORE INSERT OR UPDATE ON config.db_patch_dependencies FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates'); -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1457', :eg_version); -- gmcharlt/sandbergja +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1471', :eg_version); -- miker/sandbergja CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.oils_xpath_string.sql b/Open-ILS/src/sql/Pg/upgrade/1471.function.oils_xpath_string.sql similarity index 86% rename from Open-ILS/src/sql/Pg/upgrade/XXXX.function.oils_xpath_string.sql rename to Open-ILS/src/sql/Pg/upgrade/1471.function.oils_xpath_string.sql index b4d0581387..40e6c1feb1 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.oils_xpath_string.sql +++ b/Open-ILS/src/sql/Pg/upgrade/1471.function.oils_xpath_string.sql @@ -1,6 +1,6 @@ BEGIN; --- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); +SELECT evergreen.upgrade_deps_block_check('1471', :eg_version); CREATE OR REPLACE FUNCTION evergreen.oils_xpath_string(text, text, text, anyarray) RETURNS text AS $F$ commit 5d11af8a28317a5d202c5610f95f8c2f47e27266 Author: Mike Rylander <mrylander@gmail.com> Date: Tue Jun 3 16:31:17 2025 -0400 LP#2112412: Adding a live pgTAP test for oils_xpath_string (With a typo-fix assist from Jane!) Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Jane Sandberg <sandbergja@gmail.com> diff --git a/Open-ILS/src/sql/Pg/live_t/lp2112412-oils_xpath_string.pg b/Open-ILS/src/sql/Pg/live_t/lp2112412-oils_xpath_string.pg new file mode 100644 index 0000000000..ea2efda1d1 --- /dev/null +++ b/Open-ILS/src/sql/Pg/live_t/lp2112412-oils_xpath_string.pg @@ -0,0 +1,29 @@ +BEGIN; + +SELECT plan(4); + +SELECT is( + (select oils_xpath_string('//*[@tag="245"]','<df ind2="4" tag="245"><sf code="a">some title data</sf><sf code="0">(abc)12345</sf></df>',' -> ')), + 'some title data -> (abc)12345', + $$Works before and after LP#2112412 fix, because it DOES add //text() to expressions that return XML nodes without a function involved at the end (ie, doesn't end in a right-paren)$$ +); + +SELECT is( + (select oils_xpath_string('//*[@tag="245"]/*/@code','<df ind2="4" tag="245"><sf code="a">some title data</sf><sf code="0">(abc)12345</sf></df>')), + 'a0', + $$Works before and after LP#2112412 fix, because it doesn't add //text() to attribute-returning expressions, which always return text$$ +); + +SELECT is( + (select oils_xpath_string('//*[@tag="245"]/*[1]/text()','<df ind2="4" tag="245"><sf code="a">some title data</sf><sf code="0">(abc)12345</sf></df>')), + 'some title data', + $$Works before and after LP#2112412 fix, because it doesn't add //text() to expressions that end in the text() function, user did it for us already$$ +); + +SELECT is( + (select oils_xpath_string('substring-after(//*[@tag="245"]/*[@code="0"],")")','<df ind2="4" tag="245"><sf code="a">some title data</sf><sf code="0">(abc)12345</sf></df>')), + '12345', + $$Blows up before LP#2112412 fix, works after; we shouldn't add //text() to an expression which is wrapped in an XPath function, say, substring-after()$$ +); + +ROLLBACK; commit 7782796ba49a419ae03787d39ac396c4ceba87e5 Author: Mike Rylander <mrylander@gmail.com> Date: Tue Jun 3 12:45:30 2025 -0400 LP#2112412: oils_xpath_string is too strict Today, there is no way to construct an XPath expression for the database function oils_xpath_string() that uses an XPath function at the end of the expression, other than exactly "text()". Instead, for every expression that does not end in either an attribute (starts with "@", does not have a []'d node test) or the exact string "text()", we append the "//text()" in order to pull out the text content of all subordinate nodes in document order. That's too strict. Specifically, we should allow other functions at the end of an expression (or, indeed, wrapping the rest expression!) so that we can use the string manipulation XPath functions such as substring-after and friends. This commit changes the "should we forcibly gather all the text, or just take what the expression outputs" so that it forces the use of "text()" when: 1) the expression does not end in an attribute name, or 2) the expression does not use a function at the end of the logical evaluation process (at the end, or wrapping the whole thing) Release-note: Make oils_xpath_string more flexible WRT XPath functions. Signed-off-by: Mike Rylander <mrylander@gmail.com> Signed-off-by: Jane Sandberg <sandbergja@gmail.com> diff --git a/Open-ILS/src/sql/Pg/002.functions.config.sql b/Open-ILS/src/sql/Pg/002.functions.config.sql index 9a0d549cbb..6142a10374 100644 --- a/Open-ILS/src/sql/Pg/002.functions.config.sql +++ b/Open-ILS/src/sql/Pg/002.functions.config.sql @@ -103,7 +103,7 @@ CREATE OR REPLACE FUNCTION oils_xpath_string ( TEXT, TEXT, TEXT, ANYARRAY ) RETU SELECT ARRAY_TO_STRING( oils_xpath( $1 || - CASE WHEN $1 ~ $re$/[^/[]*@[^]]+$$re$ OR $1 ~ $re$text\(\)$$re$ THEN '' ELSE '//text()' END, + CASE WHEN $1 ~ $re$/[^/[]*@[^]]+$$re$ OR $1 ~ $re$\)$$re$ THEN '' ELSE '//text()' END, $2, $4 ), diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.oils_xpath_string.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.oils_xpath_string.sql new file mode 100644 index 0000000000..b4d0581387 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.oils_xpath_string.sql @@ -0,0 +1,19 @@ +BEGIN; + +-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +CREATE OR REPLACE FUNCTION evergreen.oils_xpath_string(text, text, text, anyarray) RETURNS text +AS $F$ + SELECT ARRAY_TO_STRING( + oils_xpath( + $1 || + CASE WHEN $1 ~ $re$/[^/[]*@[^]]+$$re$ OR $1 ~ $re$\)$$re$ THEN '' ELSE '//text()' END, + $2, + $4 + ), + $3 + ); +$F$ LANGUAGE SQL IMMUTABLE; + +COMMIT; + ----------------------------------------------------------------------- Summary of changes: Open-ILS/src/sql/Pg/002.functions.config.sql | 2 +- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- .../sql/Pg/live_t/lp2112412-oils_xpath_string.pg | 29 ++++++++++++++++++++++ .../Pg/upgrade/1471.function.oils_xpath_string.sql | 19 ++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/live_t/lp2112412-oils_xpath_string.pg create mode 100644 Open-ILS/src/sql/Pg/upgrade/1471.function.oils_xpath_string.sql hooks/post-receive -- Evergreen ILS
participants (1)
-
Git User