r1661@llin: dpavlin | 2007-11-21 11:09:52 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 21 Nov 2007 10:09:55 +0000 (10:09 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 21 Nov 2007 10:09:55 +0000 (10:09 +0000)
 fix marc_template hadling of field value 0

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1062 07558da8-63fa-0310-ba24-9fe276d99e06

TODO
lib/WebPAC/Normalize/MARC.pm
t/3-normalize-marc.t

diff --git a/TODO b/TODO
index df6ce18..3394728 100644 (file)
--- a/TODO
+++ b/TODO
@@ -49,6 +49,7 @@
 + indicator(field,nr) nr=1|2 for MARC input -> rec(field,'i1') or rec(field,'i2')
 + validator don't accept 0 as valid subfield
 + subroutines gets mungled in normalization files [2.33]
++ fix marc_template hadling of field value 0
 - rewrite WebPAC::Input to be based on Module::Pluggable
 - check usage of config in normalize file (database, input name?)
 - load_ds/save_ds should use on-disk hash to preserve inodes
index 1f5896c..2126483 100644 (file)
@@ -223,7 +223,8 @@ sub marc_template {
 
                        foreach my $sf ( @{ $_template->{$name}->{order}->{$template} } ) {
                                my ( $sf, $nr ) = @$sf;
-                               my $v = $fill_in->{$sf}->[$nr] || die "can't find fill_in $sf/$nr";
+                               my $v = $fill_in->{$sf}->[$nr];
+                               die "can't find fill_in $sf/$nr" unless defined $v;
                                if ( $name eq 'isis') {
                                        ( $sf, $nr ) = @{ $from_mapping->{$sf}->[$nr] };
                                }
index 1ed57dc..0a29c27 100755 (executable)
@@ -3,7 +3,7 @@
 use strict;
 use blib;
 
-use Test::More tests => 262;
+use Test::More tests => 325;
 
 BEGIN {
        use_ok( 'WebPAC::Test' );
@@ -49,6 +49,8 @@ my $rec = {
                'v' => 'v-8-1',
        },{
                'v' => 'v-9-1',
+       },{
+               'v' => '0',
        }],
 };
 
@@ -102,6 +104,7 @@ my $marc_out = [
        [440, "0", "1", "a", "a-7-1"],
        [440, "0", "1", "a", "a-8-1 ;", "v", "v-8-1"],
        [440, "0", "1", "v", "v-9-1"],
+       [440, 0, 1, "v", 0],
 ];
 
 is_deeply( test_marc_template($rec), $marc_out , 'is_deeply');