From 7cffd32e410d4ba65c7ea3ab6fc240dd3389b4f3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 3 Jan 2018 11:22:13 -0500 Subject: [PATCH] JBAS-1470 Multi target replaces only subfields When performing wholesale replacement of a bib field, only replace as many target fields as exist on the source record. I.e. avoid propagating and repating the same whole field multiple times into the target record. Signed-off-by: Bill Erickson --- .../sql/schema/deploy/auth-prop-partial-matches.sql | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/KCLS/sql/schema/deploy/auth-prop-partial-matches.sql b/KCLS/sql/schema/deploy/auth-prop-partial-matches.sql index 8fe051cf5e..3bf6c67fbc 100644 --- a/KCLS/sql/schema/deploy/auth-prop-partial-matches.sql +++ b/KCLS/sql/schema/deploy/auth-prop-partial-matches.sql @@ -265,17 +265,18 @@ 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. 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? + # same source field repeatedly. my @source_fields = $source_r->field($f); - my $source_field = $source_fields[++$tag_idx] - || $source_fields[$#source_fields]; + my $source_field = $source_fields[++$tag_idx]; + + if (!$source_field && @controlled_subfields) { + # When there are more target fields than source fields + # and we are replacing values for subfields and not + # performing wholesale field replacment, use the last + # available source field as the input for all remaining + # target fields. + $source_field = $source_fields[$#source_fields]; + } if (!$source_field) { # No source field exists. Delete all affected target -- 2.11.0