From: Bill Erickson Date: Tue, 2 Jan 2018 22:45:43 +0000 (-0500) Subject: JBAS-1470 Support multiple target field replacements X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=290a701eac22ba27813d3efee19b67492d6868a4;p=working%2FEvergreen.git JBAS-1470 Support multiple target field replacements Allow a single (e.g. authority) record field to act as the basis for replacing multiple like values on a target bib record. E.g. replace multiple bib 700a values from a single authority 100a value. Signed-off-by: Bill Erickson --- diff --git a/KCLS/sql/schema/deploy/auth-prop-partial-matches.sql b/KCLS/sql/schema/deploy/auth-prop-partial-matches.sql index 06ab4284e4..8fe051cf5e 100644 --- a/KCLS/sql/schema/deploy/auth-prop-partial-matches.sql +++ b/KCLS/sql/schema/deploy/auth-prop-partial-matches.sql @@ -265,8 +265,17 @@ CREATE OR REPLACE FUNCTION vandelay.replace_field # If the target record has multiple matching bib fields, # replace them from matching fields on the source record # in a predictable order to avoid replacing with them with - # same source field repeatedly. - my $source_field = ($source_r->field($f))[++$tag_idx]; + # same source field repeatedly. However, if there are more + # target fields than source fields, use the last available + # source field as the input for all remaining target fields. + # TODO: there may be cases where we do not want a single + # source field to affect multiple target fields. It works + # well when replacing multiple bib 700a values with a single + # 100a authority record value, but maybe not when overlaying + # one bib record onto another. Should this be flag/setting? + my @source_fields = $source_r->field($f); + my $source_field = $source_fields[++$tag_idx] + || $source_fields[$#source_fields]; if (!$source_field) { # No source field exists. Delete all affected target