From b2ba7022cb60a5066efe3e5a31b964100784a2a5 Mon Sep 17 00:00:00 2001 From: Yamil Suarez Date: Mon, 17 Aug 2015 16:47:34 -0400 Subject: [PATCH] LP# 1484281 auth control config update to prevent propagated data deletion Remove subfield 'e' from authority.control_set_authority_field seed values Removed from the auth tag 100 and 110, which should apply to bib tags 100,110,600,610,700,710 Added upgrade script, and pgTAP test. How to test this patch ---------------------- [1] To test this bug you need 1 authority record and at least 1 bib record. The auth record needs to have an auth 100 or 110 tag that has a subfield $e, for example 100 $aDavis, Miles $ecomposer. (for the record, it is not good cataloging practice to have $e in the auth record, but it can happen by mistake.) The bib record needs to be have a matching bib 100 or 700 tag with the same subfield $a and $e. In addition the matching bib tag has to be linked to the authority record, i.e. the bib tag has to have a bib subfield $0 with the DB id of the authority record. [2] If you open up the authority record, in the authority MARC editor, and remove the subfield $e; the subfield $e found in the bib record tag will be removed. This is a mistake because normally bib record tags 100/110/700/710 do use subfield $e, though the subfield $e should not be used in the auth record 100/110 tags. [3] When this patch is applied, if a cataloger removes a subfield $e from an auth 100/110 tag, the deletion will not cascade to its linked bibs. Signed-off-by: Yamil Suarez Signed-off-by: Jason Stephenson --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 4 ++-- ...65830_fix_auth_data_propagation_deletes.pg | 22 +++++++++++++++++++ ...ontrol_set_authority_field-remove-sf-e.sql | 11 ++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/t/regress/lp1465830_fix_auth_data_propagation_deletes.pg create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.authority.control_set_authority_field-remove-sf-e.sql diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 2532ba552e..e8bf7c1e3e 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11425,9 +11425,9 @@ INSERT INTO authority.control_set_authority_field (id, control_set, main_entry, INSERT INTO authority.control_set_authority_field (id, control_set, main_entry, tag, sf_list, display_sf_list, name) VALUES -- Main entries - (1, 1, NULL, '100', 'abcdefklmnopqrstvxyz', 'abcdefklmnopqrstvxyz', + (1, 1, NULL, '100', 'abcdfklmnopqrstvxyz', 'abcdefklmnopqrstvxyz', oils_i18n_gettext('1','Heading -- Personal Name','acsaf','name')), - (2, 1, NULL, '110', 'abcdefgklmnoprstvxyz', 'abcdefgklmnoprstvxyz', + (2, 1, NULL, '110', 'abcdfgklmnoprstvxyz', 'abcdefgklmnoprstvxyz', oils_i18n_gettext('2','Heading -- Corporate Name','acsaf','name')), (3, 1, NULL, '111', 'acdefgklnpqstvxyz', 'acdefgklnpqstvxyz', oils_i18n_gettext('3','Heading -- Meeting Name','acsaf','name')), diff --git a/Open-ILS/src/sql/Pg/t/regress/lp1465830_fix_auth_data_propagation_deletes.pg b/Open-ILS/src/sql/Pg/t/regress/lp1465830_fix_auth_data_propagation_deletes.pg new file mode 100644 index 0000000000..3f44c332d5 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/regress/lp1465830_fix_auth_data_propagation_deletes.pg @@ -0,0 +1,22 @@ +-- Load the TAP functions. +BEGIN; + +-- Plan the tests. +SELECT plan(2); + +-- Run the tests. +SELECT is( + (SELECT sf_list FROM authority.control_set_authority_field WHERE tag = '100') , + 'abcdfklmnopqrstvxyz', + 'verify that subfield "e" has been removed' +); + +SELECT is( + (SELECT sf_list FROM authority.control_set_authority_field WHERE tag = '110') , + 'abcdfgklmnoprstvxyz', + 'verify that subfield "e" has been removed' +); + +-- Finish the tests and clean up. +SELECT * FROM finish(); +ROLLBACK; \ No newline at end of file diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.authority.control_set_authority_field-remove-sf-e.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.authority.control_set_authority_field-remove-sf-e.sql new file mode 100644 index 0000000000..b33c00b029 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.authority.control_set_authority_field-remove-sf-e.sql @@ -0,0 +1,11 @@ +BEGIN; + +INSERT INTO config.upgrade_log (version) VALUES ('XXXX'); + +-- TODO: ask community if I should be warnign users that my code only fixes 100 & 110 auth tags for default (id=1) control set + +UPDATE authority.control_set_authority_field SET sf_list = REGEXP_REPLACE( sf_list, 'e', '', 'i') WHERE tag = '100' AND control_set = 1 AND sf_list ILIKE '%e%'; + +UPDATE authority.control_set_authority_field SET sf_list = REGEXP_REPLACE( sf_list, 'e', '', 'i') WHERE tag = '110' AND control_set = 1 AND sf_list ILIKE '%e%'; + +COMMIT; -- 2.43.2