From 6759a889bd1c3beb02255cd68ca5cf41702b0822 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Thu, 21 Jul 2011 12:14:02 -0400 Subject: [PATCH] Prevent control numbers from duplicating In maintain_control_numbers(), if you have more than one 001 or 003, and at least one is the correct one, you will end up duplicating the correct number every time the record is saved. For example, if the incoming record was record ID # 12345, and the record contained: 001: 12345 001: ocm10202 ... then after maintain_control_numbers() ran, the record would contain: 001: 12345 001: 12345 Also, clean up some leftovers from the refactor I suggested in the previous commit. Signed-off-by: Dan Wells Signed-off-by: Dan Scott --- Open-ILS/src/sql/Pg/002.functions.config.sql | 7 +------ .../upgrade/xxxx.maintain_control_numbers_with_OCLC_awareness.sql | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Open-ILS/src/sql/Pg/002.functions.config.sql b/Open-ILS/src/sql/Pg/002.functions.config.sql index fefae05111..353c7f2139 100644 --- a/Open-ILS/src/sql/Pg/002.functions.config.sql +++ b/Open-ILS/src/sql/Pg/002.functions.config.sql @@ -553,9 +553,7 @@ foreach my $id_field ('001', '003') { } else { # Delete the other fields, as with more than 1 001/003 we do not know which 003/001 to match foreach my $control (@controls) { - unless ($control->data() eq $spec_value) { - $record->delete_field($control); - } + $record->delete_field($control); } $record->insert_fields_ordered(MARC::Field->new($id_field, $spec_value)); $create = 1; @@ -581,9 +579,6 @@ if ($munge and not $create) { unless (grep $_->subfield('a') eq $scn, @scns) { $record->insert_fields_ordered(MARC::Field->new('035', '', '', 'a' => $scn)); } - - # Update the list of SCNs to avoid duplicates - @scns = $record->field('035'); } # Set the 001/003 and update the MARC diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.maintain_control_numbers_with_OCLC_awareness.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.maintain_control_numbers_with_OCLC_awareness.sql index dd386f0d25..784744de72 100644 --- a/Open-ILS/src/sql/Pg/upgrade/xxxx.maintain_control_numbers_with_OCLC_awareness.sql +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.maintain_control_numbers_with_OCLC_awareness.sql @@ -66,9 +66,7 @@ foreach my $id_field ('001', '003') { } else { # Delete the other fields, as with more than 1 001/003 we do not know which 003/001 to match foreach my $control (@controls) { - unless ($control->data() eq $spec_value) { - $record->delete_field($control); - } + $record->delete_field($control); } $record->insert_fields_ordered(MARC::Field->new($id_field, $spec_value)); $create = 1; @@ -94,9 +92,6 @@ if ($munge and not $create) { unless (grep $_->subfield('a') eq $scn, @scns) { $record->insert_fields_ordered(MARC::Field->new('035', '', '', 'a' => $scn)); } - - # Update the list of SCNs to avoid duplicates - @scns = $record->field('035'); } # Set the 001/003 and update the MARC -- 2.11.0