Bug 28048

Summary: Can't import patrons without checkprevcheckout and autorenew_checkouts
Product: Koha Reporter: Nitesh Kumar Verma <vermanite>
Component: ToolsAssignee: Bugs List <koha-bugs>
Status: CLOSED WORKSFORME QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: jonathan.druart
Version: Main   
Hardware: All   
OS: All   
GIT URL: Initiative type: ---
Sponsorship status: --- Comma delimited list of Sponsors:
Crowdfunding goal: 0 Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Attachments: Screenshot of error

Description Nitesh Kumar Verma 2021-03-28 06:21:07 UTC
Created attachment 118917 [details]
Screenshot of error

Getting Internal Server Error While importing patrons in .CSV format.
This error occurs only when I am trying to import new patrons in CSV format.

Server Details:

OS: Ubuntu 16.04 LTS
KOHA Version: 16.11.14.000
MySQL version:	mysql Ver 14.14 Distrib 5.7.33
Comment 1 Owen Leonard 2021-03-30 14:18:28 UTC
I don't know if this is the same issue, but I'll take over this bug since there are no other details:

Although they're not mentioned on the page as required field, it doesn't seem to be possible to import a CSV of patrons without putting a value in the checkprevcheckout and autorenew_checkouts columns.

An error appears in the log if you omit them:

[WARN] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Column 'autorenew_checkouts' cannot be null [for Statement "UPDATE `borrowers` SET `autorenew_checkouts` = ?, `checkprevcheckout` = ?, `dateexpiry` = ?, `dateofbirth` = ?, `debarred` = ?, `flags` = ?, `gonenoaddress` = ?, `lang` = ?, `lost` = ?, `password` = ?, `relationship` = ?, `updated_on` = current_timestamp, `userid` = ? WHERE ( `borrowernumber` = ? )" with ParamValues: 0=undef, 1=undef, 2='2024-03-30T00:00:00', 3=undef, 4=undef, 5=undef, 6=undef, 7=undef, 8=undef, 9='!', 10=undef, 11='test.test', 12='65581'] at /kohadevbox/koha/Koha/Object.pm line 169

[WARN] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Column 'checkprevcheckout' cannot be null [for Statement "UPDATE `borrowers` SET `checkprevcheckout` = ?, `dateexpiry` = ?, `dateofbirth` = ?, `debarred` = ?, `flags` = ?, `gonenoaddress` = ?, `lang` = ?, `lost` = ?, `password` = ?, `relationship` = ?, `updated_on` = current_timestamp, `userid` = ? WHERE ( `borrowernumber` = ? )" with ParamValues: 0=undef, 1='2024-03-30T00:00:00', 2=undef, 3=undef, 4=undef, 5=undef, 6=undef, 7=undef, 8='!', 9=undef, 10='test.test', 11='65581'] at /kohadevbox/koha/Koha/Object.pm line 169
Comment 2 Nitesh Kumar Verma 2021-03-30 14:47:26 UTC
Owen Sir,
I am using ../cgi-bin/koha/tools/import_borrowers.pl to import patron in .CSV format. I have upgraded from koha version from 16.05 to 16.11. After upgrading I am facing this error. I am using the same method as I have used earlier. Running KOHA since 2015 and have more than 8000 patron records.

CSV Headers I am using: cardnumber,surname,patron_attributes,phone,address,branchcode,categorycode,email,password,userid.

I am stuck in between as it is not possible to manually enter the details of 3000-4000 patron details on KOHA.

Any help in this regard is highly appreciated.
Comment 3 Owen Leonard 2021-03-30 15:24:26 UTC
(In reply to Nitesh Kumar Verma from comment #2)
> I have upgraded from koha version from 16.05 to 16.11.

I'm sorry but 16.11 is a very old Koha version and isn't supported anymore.
Comment 4 Jonathan Druart 2021-04-26 09:48:48 UTC
I don't recreate, Owen.

I tried to create and update a patron with a csv without and without autorenew_checkouts, checkprevcheckout in the headers (and no value), but they got created/updated correctly.
Comment 5 Jonathan Druart 2021-04-26 09:49:35 UTC
Looks like the following change is needed

@ Koha/Patrons/Import.pm:238 @ sub import_patrons {
         # Remove warning for int datatype that cannot be null
         # Argument "" isn't numeric in numeric eq (==) at /usr/share/perl5/DBIx/Class/Row.pm line 1018
         for my $field (
-            qw( privacy privacy_guarantor_fines privacy_guarantor_checkouts anonymized login_attempts ))
+            qw( privacy privacy_guarantor_fines privacy_guarantor_checkouts anonymized login_attempts autorenew_checkouts ))
Comment 6 Nitesh Kumar Verma 2021-04-26 14:33:44 UTC
Thanks Owen Leonard & Jonathan Druart for your perusal. I have updated from Mysql to MariaDB and the said problem resolved automatically.