Bug 19492

Summary: Field 'lowestPriority' doesn't have a default value (MariaDB)
Product: Koha Reporter: Magnus Enger <magnus>
Component: Hold requestsAssignee: Bugs List <koha-bugs>
Status: RESOLVED DUPLICATE QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: gmcharlt, jonathan.druart
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 17258    

Description Magnus Enger 2017-10-19 07:00:55 UTC
Running Koha with MariaDB on Ubuntu 16.04, I get an "internal server error" when I try to add a hold. The Plack log says: 

DBD::mysql::st execute failed: Field 'lowestPriority' doesn't have a default value [for Statement "INSERT INTO `reserves` ( `biblionumber`, `borrowernumber`, `branchcode`, `expirationdate`, `found`, `itemnumber`, `itemtype`, `priority`, `reservedate`, `reservenotes`, `waitingdate`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0="16303", 1='1', 2="LIB", 3=undef, 4=undef, 5=undef, 6=undef, 7="1", 8='2017-10-19', 9="", 10=undef] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1834.
DBIx::Class::Storage::DBI::_dbh_execute(): Field 'lowestPriority' doesn't have a default value at /home/kohaadmin/kohaclone/Koha/Object.pm line 121

And reserves.lowestPriority does indeed not have a default value (from installer/data/mysql/kohastructure.sql): 

`lowestPriority` tinyint(1) NOT NULL,

Adding a default value of 0 makes the "internal server error" go away:

ALTER TABLE reserves ALTER COLUMN lowestPriority SET DEFAULT 0;
Comment 1 Jonathan Druart 2017-10-20 18:19:47 UTC
What is the version of MariaDB?
Did you modify my.cnf?
Does `grep -r sql-mode /etc/mysql` return something?
Comment 2 Magnus Enger 2017-10-30 20:36:55 UTC
(In reply to Jonathan Druart from comment #1)
> What is the version of MariaDB?

10.2.9-MariaDB-10.2.9+maria~xenial

> Did you modify my.cnf?

Don't think so.

> Does `grep -r sql-mode /etc/mysql` return something?

$ sudo grep -r sql-mode /etc/mysql
/etc/mysql/mysql.conf.d/mysqld.cnf:sql-mode="IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Comment 3 Jonathan Druart 2017-11-02 11:54:07 UTC
The "doesn't have a default value" is related to the STRICT_TRANS_TABLES mode, with NO_ENGINE_SUBSTITUTION you should not get this error.

Can you confirm you restarted the service and you still get this error?
Comment 4 Jonathan Druart 2018-02-06 20:52:33 UTC
Will be fixed by bug 20144.

*** This bug has been marked as a duplicate of bug 20144 ***