Bugzilla – Attachment 187184 Details for
Bug 32950
MARC modification template moving subfield can lose values for repeatable fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32950: Add unit test for move_field with repeatable fields
Bug-32950-Add-unit-test-for-movefield-with-repeata.patch (text/plain), 2.97 KB, created by
Martin Renvoize (ashimema)
on 2025-10-01 12:36:34 UTC
(
hide
)
Description:
Bug 32950: Add unit test for move_field with repeatable fields
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-10-01 12:36:34 UTC
Size:
2.97 KB
patch
obsolete
>From 50a949aad1d4b409d4e3603a79ee3ede6357ab6e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Tue, 23 Sep 2025 10:08:15 +0100 >Subject: [PATCH] Bug 32950: Add unit test for move_field with repeatable > fields > >This test reproduces the issue where moving subfields between >repeatable MARC fields can lose or duplicate values. The test >verifies that when moving 020$z to 024$a fields, the values >are correctly transferred in the proper order without duplication. > >Signed-off-by: Bernard Scaife <bernard.scaife@openfifth.co.uk> >--- > t/SimpleMARC.t | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 49 insertions(+), 1 deletion(-) > >diff --git a/t/SimpleMARC.t b/t/SimpleMARC.t >index 9c8c1dbba50..4da903d3702 100755 >--- a/t/SimpleMARC.t >+++ b/t/SimpleMARC.t >@@ -1334,7 +1334,7 @@ subtest 'copy_and_replace_field' => sub { > subtest 'move_field' => sub { > plan tests => 2; > subtest 'move subfield' => sub { >- plan tests => 7; >+ plan tests => 9; > my $record = new_record; > my ( @fields_952d, @fields_952c, @fields_954c, @fields_954p ); > $record->append_fields( >@@ -1414,6 +1414,54 @@ subtest 'move_field' => sub { > \@fields_9999, [], > 'move a nonexistent subfield does not create a new one' > ); >+ >+ # Test for bug 32950: Moving subfield can lose values for repeatable fields >+ $record = new_record; >+ $record->append_fields( >+ MARC::Field->new( >+ '020', ' ', ' ', >+ a => '123456789', >+ z => '987654321', >+ ), >+ MARC::Field->new( >+ '020', ' ', ' ', >+ a => '111111111', >+ z => '222222222', >+ ), >+ MARC::Field->new( >+ '020', ' ', ' ', >+ a => '333333333', >+ z => '444444444', >+ ), >+ MARC::Field->new( >+ '024', ' ', ' ', >+ a => 'existing1', >+ ), >+ MARC::Field->new( >+ '024', ' ', ' ', >+ a => 'existing2', >+ ), >+ ); >+ >+ # Test moving to a different field to reproduce the bug more clearly >+ move_field( >+ { >+ record => $record, >+ from_field => '020', >+ from_subfield => 'z', >+ to_field => '024', >+ to_subfield => 'a' >+ } >+ ); >+ >+ my @fields_020z = read_field( { record => $record, field => '020', subfield => 'z' } ); >+ my @fields_024a = read_field( { record => $record, field => '024', subfield => 'a' } ); >+ is_deeply( \@fields_020z, [], 'All 020$z subfields have been moved' ); >+ is_deeply( >+ \@fields_024a, >+ [ '987654321', '222222222', '444444444' ], >+ 'Bug 32950: Move preserves values correctly in repeatable fields' >+ ); > }; > > subtest 'move field' => sub { >-- >2.51.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32950
:
146586
|
186781
|
186782
|
187184
|
187185
|
187186
|
187187
|
187450
|
187451
|
187452
|
187538