Bug 22025 - Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1018 for /usr/share/koha/bin/import_patrons.pl
Summary: Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/R...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All Linux
: P4 minor
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-18 22:41 UTC by mjnkml
Modified: 2020-11-30 21:47 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00, 19.11.05
Circulation function:


Attachments
Bug 22025: Add a regression test (1.31 KB, patch)
2020-03-16 14:46 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 22025: Remove warnings when importing patrons (1.62 KB, patch)
2020-03-16 14:46 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 22025: Add a regression test (1.36 KB, patch)
2020-03-17 14:08 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 22025: Remove warnings when importing patrons (1.73 KB, patch)
2020-03-17 14:08 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 22025: Add a regression test (1.43 KB, patch)
2020-03-20 13:30 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 22025: Remove warnings when importing patrons (1.80 KB, patch)
2020-03-20 13:30 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description mjnkml 2018-12-18 22:41:27 UTC
When running:

> sudo koha-shell -v -c "/usr/share/koha/bin/import_patrons.pl --file /home/kohasync/incomingfile/borrowers.csv --matchpoint userid --confirm --overwrite --verbose" our_instance_name

We get a bunch of:

> Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1018, <$handle> line 490.

per import row.

When I add some say STDERR lines just before it, I get:

> Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1019, <$handle> line 490.
> OLD: 0, NEW: , COL: lost
> 
> Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1019, <$handle> line 490.
> OLD: 0, NEW: , COL: privacy_guarantor_checkouts
> 
> Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1019, <$handle> line 490.
> OLD: 0, NEW: , COL: lost
> 

None of those fields (privacy_guarantor_checkouts, lost, etc.) are included in the CSV import.
Comment 1 Jonathan Druart 2018-12-19 20:59:29 UTC
I am expecting to see these warnings removed by bug 21596, but the patches will not be backported into 18.05.x

I will try to confirm that later.
Comment 2 mjnkml 2018-12-26 15:59:08 UTC
Just FYI - I've upgraded to 18.11.01.000 and the behaviour seems the same.
Comment 3 Jonathan Druart 2019-03-04 19:15:39 UTC
I do not recreate against master, can you share an example file?
Comment 4 Jonathan Druart 2019-03-04 19:17:46 UTC
I would expect the warnings to appear if you are doing an update, not an insert.
Comment 5 Magnus Enger 2019-08-09 07:58:09 UTC
I see these warnings for updates, on 18.11.05.000. When I do this:

  elsif ($self->_is_column_numeric($col)) {  # do a numeric comparison if datatype allows it
    warn $col;
    return $old == $new;
  }

it seems that the privacy_guarantor_checkouts field is the culprit. All the borrowers in the database have a 0 value for this column, do maybe there is a false assumption that the new patron data will always have a numeric value for this field, but in fact it is just empty if it is not included in the imported data?
Comment 6 Magnus Enger 2019-08-09 08:00:02 UTC
Could something like this be a solution? 

  elsif ($new && $self->_is_column_numeric($col)) {  # do a numeric comparison if datatype allows it
    return $old == $new;
  }
Comment 7 Katrin Fischer 2019-08-10 20:38:15 UTC
Updating the version according to comments.
Comment 8 Magnus Enger 2020-03-13 14:06:17 UTC
Had another look at this, and it looks like the "Argument "" isn't numeric in numeric" is triggered for culumns that have a default_value of 0.
Comment 9 Jonathan Druart 2020-03-16 14:46:47 UTC Comment hidden (obsolete)
Comment 10 Jonathan Druart 2020-03-16 14:46:51 UTC Comment hidden (obsolete)
Comment 11 Magnus Enger 2020-03-17 14:08:19 UTC
Created attachment 100893 [details] [review]
Bug 22025: Add a regression test

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Comment 12 Magnus Enger 2020-03-17 14:08:22 UTC
Created attachment 100894 [details] [review]
Bug 22025: Remove warnings when importing patrons

The following warning is raised when importing patrons
Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1018

if one of the following headers is passed but does not have a value:
 * privacy
 * privacy_guarantor_fines
 * privacy_guarantor_checkouts
 * anonymized

Test plan:
- Do not apply the patch
- Generated a csv file with at least one those headers
- Import it using the import_patrons.pl script (or using the GUI)
- Notice the warnings without the patch
- Apply the patch
- Confirm that the warnings do not longer appear

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Applied the patch on a live server and the warnings went away.
Comment 13 Magnus Enger 2020-03-17 14:12:18 UTC
I do get a bunch of errors when I try to run the tests in kohadevbox, but that might be caused by bad data in my instance? 

$ sudo koha-shell -c "prove t/db_dependent/Koha/Patrons/Import.t" kohadev
t/db_dependent/Koha/Patrons/Import.t .. 1/157 
#   Failed test 'Got the expected 0 size error array from import_patrons with no matchpoint defined'
#   at t/db_dependent/Koha/Patrons/Import.t line 105.
#          got: '2'
#     expected: '0'

#   Failed test 'Got the expected second feedback from import_patrons with no matchpoint defined'
#   at t/db_dependent/Koha/Patrons/Import.t line 111.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected last imported name from import_patrons with no matchpoint defined'
#   at t/db_dependent/Koha/Patrons/Import.t line 112.
#          got: undef
#     expected: 'lastimported'

#   Failed test 'Got the expected second header row value from import_patrons with no matchpoint defined'
#   at t/db_dependent/Koha/Patrons/Import.t line 113.
#                   undef
#     doesn't match '(?^u:^Nancy / \d+)'

#   Failed test 'Got the expected 1 imported result from import_patrons with no matchpoint defined'
#   at t/db_dependent/Koha/Patrons/Import.t line 115.
#          got: '0'
#     expected: '1'

#   Failed test 'Got the expected 0 invalid result from import_patrons with no matchpoint defined'
#   at t/db_dependent/Koha/Patrons/Import.t line 116.
#          got: '1'
#     expected: '0'

#   Failed test 'Got the expected 1000 card number from import patrons with invalid card number'
#   at t/db_dependent/Koha/Patrons/Import.t line 130.
#          got: undef
#     expected: '1000'

#   Failed test 'Got the expected invalid card number from import patrons with invalid card number'
#   at t/db_dependent/Koha/Patrons/Import.t line 131.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected 1 already_in_db from import_patrons with duplicate userid'
#   at t/db_dependent/Koha/Patrons/Import.t line 150.
#          got: '0'
#     expected: '1'

#   Failed test 'Got the expected 0 invalid result from import_patrons'
#   at t/db_dependent/Koha/Patrons/Import.t line 159.
#          got: '1'
#     expected: '0'

#   Failed test 'Got the expected 0 invalid result from import_patrons'
#   at t/db_dependent/Koha/Patrons/Import.t line 180.
#          got: '1'
#     expected: '0'

#   Failed test 'Got the expected 1 overwritten result from import_patrons that matched'
#   at t/db_dependent/Koha/Patrons/Import.t line 181.
#          got: '0'
#     expected: '1'

#   Failed test 'Got the expected duplicate userid error from import patrons with duplicate userid'
#   at t/db_dependent/Koha/Patrons/Import.t line 193.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected userid error from import patrons with duplicate userid'
#   at t/db_dependent/Koha/Patrons/Import.t line 194.
#          got: undef
#     expected: 'jjenkins0'
t/db_dependent/Koha/Patrons/Import.t .. 57/157 
#   Failed test 'Got the expected 0 size error array from import_patrons with extended user'
#   at t/db_dependent/Koha/Patrons/Import.t line 220.
#          got: '2'
#     expected: '0'

#   Failed test 'Got the expected third feedback from import_patrons with extended user'
#   at t/db_dependent/Koha/Patrons/Import.t line 230.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected last imported name from import_patrons with extended user'
#   at t/db_dependent/Koha/Patrons/Import.t line 231.
#          got: undef
#     expected: 'lastimported'

#   Failed test 'Got the expected third feedback value from import_patrons with extended user'
#   at t/db_dependent/Koha/Patrons/Import.t line 232.
#                   undef
#     doesn't match '(?^u:^Donna / \d+)'

#   Failed test 'Got the expected 1 imported result from import_patrons with extended user'
#   at t/db_dependent/Koha/Patrons/Import.t line 234.
#          got: '0'
#     expected: '1'

#   Failed test 'Got the expected 0 invalid result from import_patrons with extended user'
#   at t/db_dependent/Koha/Patrons/Import.t line 235.
#          got: '1'
#     expected: '0'

#   Failed test 'Got the expected 1 already_in_db from import_patrons with extended user matched'
#   at t/db_dependent/Koha/Patrons/Import.t line 240.
#          got: '0'
#     expected: '1'

#   Failed test 'Got the expected 0 size error array from import_patrons with extended user matched'
#   at t/db_dependent/Koha/Patrons/Import.t line 241.
#          got: '2'
#     expected: '0'

#   Failed test 'Got the expected already_in_db from import_patrons with extended user matched'
#   at t/db_dependent/Koha/Patrons/Import.t line 251.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected third feedback value from import_patrons with extended user matched'
#   at t/db_dependent/Koha/Patrons/Import.t line 252.
#                   undef
#     doesn't match '(?^u:^Donna / \d+)'

#   Failed test 'Got the expected 0 invalid result from import_patrons with extended user matched'
#   at t/db_dependent/Koha/Patrons/Import.t line 255.
#          got: '1'
#     expected: '0'

#   Failed test 'Got the expected undef borrower number error from import patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 282.
#          got: undef
#     expected: 'UNDEF'

#   Failed test 'Got the expected 1 branchmap error from import patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 283.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected branch code key from import patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 284.
#          got: undef
#     expected: 'branchcode'

#   Failed test 'Got the expected 4 line number error from import patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 285.
#          got: undef
#     expected: '4'

#   Failed test 'Got the expected lineraw error from import patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 286.
Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105, <$handle_5> line 4.
#          got: undef
#     expected: '1005,Chloé❤,Greene,Mr,Michael,RG,3,Avenue,Grim,Peoria,Jacksonville,Illinois,61614,United States,mgreene5@seesaa.net,3-(941)565-5752,1-(483)885-8138,4-(979)577-6908,02/09/1957,ZZZ,ST,04/02/2015,07/01/2015,mgreene5,or4ORT6JH
# '

#   Failed test 'Got the expected surname error from import patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 287.
Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105, <$handle_5> line 4.
#          got: undef
#     expected: 'Chloé❤'

#   Failed test 'Got the expected ZZZ value error from import patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 288.
#          got: undef
#     expected: 'ZZZ'

#   Failed test 'Got the expected 1 feedback from import_patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 294.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected lastimported name from import_patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 295.
#          got: undef
#     expected: 'lastimported'

#   Failed test 'Got the expected last imported value from import_patrons with for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 296.
Wide character in print at /usr/share/perl5/Test2/Formatter/TAP.pm line 105, <$handle_5> line 4.
#                   undef
#     doesn't match '(?^u:^Chloé❤ / \d+)'

#   Failed test 'Got the expected 1 imported result from import patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 298.
#          got: '0'
#     expected: '1'

#   Failed test 'Got the expected 2 invalid result from import patrons for branch tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 299.
#          got: '3'
#     expected: '2'

#   Failed test 'Got the expected undef borrower number error from import patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 323.
#          got: undef
#     expected: 'UNDEF'

#   Failed test 'Got the expected 1 category_map error from import patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 324.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected category code key from import patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 325.
#          got: undef
#     expected: 'categorycode'

#   Failed test 'Got the expected 4 line number error from import patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 326.
#          got: undef
#     expected: '4'

#   Failed test 'Got the expected lineraw error from import patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 327.
#          got: undef
#     expected: '1008,Emily,Richards,Ms,Judy,ER,73,Way,Kedzie,Fort Wayne,Phoenix,Indiana,46825,United States,jrichards8@arstechnica.com,5-(266)658-8957,3-(550)500-9107,7-(816)675-9822,08/09/1984,FFL,ZZ,11/09/2014,07/01/2015,jrichards8,D5PvU6H2R
# '

#   Failed test 'Got the expected surname error from import patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 328.
#          got: undef
#     expected: 'Emily'

#   Failed test 'Got the expected ZZ value error from import patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 329.
#          got: undef
#     expected: 'ZZ'

#   Failed test 'Got the expected 1 feedback from import_patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 335.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected lastimported name from import_patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 336.
#          got: undef
#     expected: 'lastimported'

#   Failed test 'Got the expected last imported value from import_patrons with for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 337.
#                   undef
#     doesn't match '(?^u:^Peter / \d+)'

#   Failed test 'Got the expected 1 imported result from import patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 339.
#          got: '0'
#     expected: '1'

#   Failed test 'Got the expected 2 invalid result from import patrons for category tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 340.
#          got: '3'
#     expected: '2'

#   Failed test 'Got the expected 1 error array size from import_patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 356.
#          got: '3'
#     expected: '1'

#   Failed test 'Got the expected 3 missing critical errors from import_patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 357.
#          got: '0'
#     expected: '3'

#   Failed test 'Got the expected 1 bad_date error from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 359.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected undef borrower number error from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 360.
#          got: undef
#     expected: 'UNDEF'

#   Failed test 'Got the expected dateofbirth key from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 361.
#          got: undef
#     expected: 'dateofbirth'

#   Failed test 'Got the expected 2 line number error from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 362.
#          got: undef
#     expected: '3'

#   Failed test 'Got the expected lineraw error from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 363.
#          got: undef
#     expected: '1010,Ralph,Warren,Ms,Linda,RW,6,Way,Barby,Orlando,Albany,Florida,32803,United States,lwarrena@multiply.com,7-(579)753-7752,6-(847)086-7566,9-(122)729-8226,26/01/2001,LPL,T,25/01/2001,24/01/2001,lwarrena,tJ56RD4uV
# '

#   Failed test 'Got the expected surname error from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 364.
#          got: undef
#     expected: 'Ralph'

#   Failed test 'Got the expected dateenrolled key from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 366.
#          got: undef
#     expected: 'dateenrolled'

#   Failed test 'Got the expected dateexpiry key from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 367.
#          got: undef
#     expected: 'dateexpiry'

#   Failed test 'Got the expected 2 feedback from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 369.
#          got: '1'
#     expected: '2'

#   Failed test 'Got the expected 1 feedback from import_patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 374.
#          got: undef
#     expected: '1'

#   Failed test 'Got the expected lastimported from import_patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 375.
#          got: undef
#     expected: 'lastimported'

#   Failed test 'Got the expected lastimported value from import_patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 376.
#                   undef
#     doesn't match '(?^u:^Christina / \d+)'

#   Failed test 'Got the expected 1 imported result from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 378.
#          got: '0'
#     expected: '1'

#   Failed test 'Got the expected 1 invalid result from import patrons for dates tests'
#   at t/db_dependent/Koha/Patrons/Import.t line 379.
#          got: '2'
#     expected: '1'
t/db_dependent/Koha/Patrons/Import.t .. 149/157 # Looks like you failed 65 tests of 157.
t/db_dependent/Koha/Patrons/Import.t .. Dubious, test returned 65 (wstat 16640, 0x4100)
Failed 65/157 subtests 

Test Summary Report
-------------------
t/db_dependent/Koha/Patrons/Import.t (Wstat: 16640 Tests: 157 Failed: 65)
  Failed tests:  10, 14-18, 22-23, 30, 37, 46-47, 49-50
                58, 65-69, 71-72, 79-80, 82, 90-96, 100-104
                112-118, 122-126, 129-139, 143-147
  Non-zero exit status: 65
Files=1, Tests=157,  8 wallclock secs ( 0.04 usr  0.02 sys +  6.90 cusr  0.36 csys =  7.32 CPU)
Result: FAIL

The test added by the current patch changes this to "Failed 65/158 subtests", so at least it seems the added test is passing.
Comment 14 Kyle M Hall (khall) 2020-03-20 13:30:36 UTC
Created attachment 101106 [details] [review]
Bug 22025: Add a regression test

Signed-off-by: Magnus Enger <magnus@libriotech.no>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 15 Kyle M Hall (khall) 2020-03-20 13:30:45 UTC
Created attachment 101107 [details] [review]
Bug 22025: Remove warnings when importing patrons

The following warning is raised when importing patrons
Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1018

if one of the following headers is passed but does not have a value:
 * privacy
 * privacy_guarantor_fines
 * privacy_guarantor_checkouts
 * anonymized

Test plan:
- Do not apply the patch
- Generated a csv file with at least one those headers
- Import it using the import_patrons.pl script (or using the GUI)
- Notice the warnings without the patch
- Apply the patch
- Confirm that the warnings do not longer appear

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Applied the patch on a live server and the warnings went away.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 16 Martin Renvoize (ashimema) 2020-03-20 15:43:19 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 17 Joy Nelson 2020-04-03 21:22:19 UTC
backported to 19.11.x for 19.11.05