View | Details | Raw Unified | Return to bug 26781
Collapse All | Expand All

(-)a/Koha/SimpleMARC.pm (-1 / +1 lines)
Lines 526-532 sub delete_field { Link Here
526
    my $subfieldName = $params->{subfield};
526
    my $subfieldName = $params->{subfield};
527
    my $field_numbers = $params->{field_numbers} // [];
527
    my $field_numbers = $params->{field_numbers} // [];
528
528
529
    if ( not $subfieldName or $subfieldName eq '' ) {
529
    if ( !defined $subfieldName or $subfieldName eq '' ) {
530
        _delete_field({ record => $record, field => $fieldName, field_numbers => $field_numbers });
530
        _delete_field({ record => $record, field => $fieldName, field_numbers => $field_numbers });
531
    } else {
531
    } else {
532
        _delete_subfield({ record => $record, field => $fieldName, subfield => $subfieldName, field_numbers => $field_numbers });
532
        _delete_subfield({ record => $record, field => $fieldName, subfield => $subfieldName, field_numbers => $field_numbers });
(-)a/t/SimpleMARC.t (-2 / +13 lines)
Lines 1676-1682 subtest 'move_field' => sub { Link Here
1676
subtest 'delete_field' => sub {
1676
subtest 'delete_field' => sub {
1677
    plan tests                => 2;
1677
    plan tests                => 2;
1678
    subtest 'delete subfield' => sub {
1678
    subtest 'delete subfield' => sub {
1679
        plan tests => 2;
1679
        plan tests => 3;
1680
        my $record = new_record;
1680
        my $record = new_record;
1681
        $record->append_fields(
1681
        $record->append_fields(
1682
            MARC::Field->new(
1682
            MARC::Field->new(
Lines 1710-1715 subtest 'delete_field' => sub { Link Here
1710
        @fields_952p =
1710
        @fields_952p =
1711
          read_field( { record => $record, field => '952', subfield => 'p' } );
1711
          read_field( { record => $record, field => '952', subfield => 'p' } );
1712
        is_deeply( \@fields_952p, [], 'Delete all 952$p' );
1712
        is_deeply( \@fields_952p, [], 'Delete all 952$p' );
1713
1714
        $record = new_record;
1715
        $record->append_fields(
1716
            MARC::Field->new(
1717
                600, ' ', ' ',
1718
                a => 'Murakami, Haruki',
1719
                0 => 'https://id.loc.gov/authorities/names/n81152393.html',
1720
            ),
1721
        );
1722
        delete_field( { record => $record, field => '600', subfield => '0' } );
1723
        my @fields_600 = read_field( { record => $record, field => '600' } );
1724
        is_deeply( \@fields_600, ['Murakami, Haruki'], 'Delete all 600$0, ony subfield 0 deleted' );
1713
    };
1725
    };
1714
1726
1715
    subtest 'delete field' => sub {
1727
    subtest 'delete field' => sub {
1716
- 

Return to bug 26781