Description
Mark Tompsett
2016-09-20 23:31:47 UTC
Created attachment 55727 [details] [review] Bug 17324: Deal with branchcode NULL issue Created attachment 55728 [details] [review] Bug 17324: Deal with branchcode NULL issue Okay, I was wrong about the bug 14839. I vaguely recall the cascading of deletion with '' vs NULL being an issue for some reason when I was working on news by branchcode, but I don't remember the scenario. Follow the test plan in the description. You'll get a "pristine" (two messages about a system preference that gets deleted later) install. Created attachment 56041 [details] [review] Bug 17324: Deal with branchcode NULL issue In a database update we alter the letter table, making a column (branchcode) not be able to contain NULL values. However if it already does, this SQL fails. So before changing the column we change the NULL values [Tue Sep 20 19:08:10 2016] updatedatabase.pl: DBD::mysql::db do failed: Invalid use of NULL value [for Statement " [Tue Sep 20 19:08:10 2016] updatedatabase.pl: ALTER TABLE letter MODIFY COLUMN branchcode varchar(10) NOT NULL DEFAULT '' [Tue Sep 20 19:08:10 2016] updatedatabase.pl: "] at /home/mtompset/kohaclone/installer/data/mysql/updatedatabase.pl line 12638. Reproduce: on an ubuntu 16.04 LTS machine with MySQL 5.7 install git koha development environment. ... git checkout -b my_3.18.x origin/3.18.x drop database koha_library; create database koha_library; quit; web install all sample data (ignore some issues with sample data, and one with mandatory) git checkout -b bug_17234 origin/master git bz apply 17292 git bz apply 17320 git bz apply 17260 git bz apply 17234 web install Two warning messages are expected output from upgrade process, but the above message is not. Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> Signed off and fixed the commit message. Created attachment 56049 [details] [review] Bug 17324: Deal with branchcode NULL issue In a database update we alter the letter table, making a column (branchcode) not be able to contain NULL values. However if it already does, this SQL fails. So before changing the column we change the NULL values [Tue Sep 20 19:08:10 2016] updatedatabase.pl: DBD::mysql::db do failed: Invalid use of NULL value [for Statement " [Tue Sep 20 19:08:10 2016] updatedatabase.pl: ALTER TABLE letter MODIFY COLUMN branchcode varchar(10) NOT NULL DEFAULT '' [Tue Sep 20 19:08:10 2016] updatedatabase.pl: "] at /home/mtompset/kohaclone/installer/data/mysql/updatedatabase.pl line 12638. Reproduce: on an ubuntu 16.04 LTS machine with MySQL 5.7 install git koha development environment. ... git checkout -b my_3.18.x origin/3.18.x drop database koha_library; create database koha_library; quit; web install all sample data (ignore some issues with sample data, and one with mandatory) git checkout -b bug_17234 origin/master git bz apply 17292 git bz apply 17320 git bz apply 17260 git bz apply 17234 web install Two warning messages are expected output from upgrade process, but the above message is not. Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Did not follow the test plan, but the changes make sense Mark, did you get how it happened? (In reply to Jonathan Druart from comment #7) > Mark, did you get how it happened? Ah. I think I figured out how. I got it to happen as a result of tweaking PRIMARY to UNIQUE (see bug 17234) as part of upgrade testing. Whereas, the preferred option, by other newer patches, was to change NULL to ''. NULL cascades nicely on relationships, '' does not in my experience. I also just attempted playing around with upgrading and downgrading MySQL. http://repo.mysql.com/ It would seem that upgrading your MySQL to 5.7 isn't likely to encounter this problem. Anyways, this is explicit, rather than assuming MySQL's implicit tweaking of NULL to ''. Pushed to Master - Should be in the November Release 16.11 - Thanks! Pushed in 16.05. Will be in 16.05.05. Pushed to 3.22.x, will be in 3.22.12 |