From cc002b006b192ffb0f8690ac83fcd73251281975 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Thu, 11 Jul 2024 14:54:26 +0200 Subject: [PATCH] Bug 18086: Fix issues with NULL for categories See https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18086#c27 for more context : This addresses the 4th point of this comment. A few tests do not pass because they test the behaviour of functions concerning categoriees on an empty string, whi ch is now forbidden due to the foreign key constraint. I propose changes for categoriees and for categories in two different patches, changing the behaviour of functions so that they interprete NULL in db as the default rule. --- installer/data/mysql/kohastructure.sql | 2 +- t/db_dependent/Overdues.t | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index bbd72d4..76e24d5 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4963,7 +4963,7 @@ DROP TABLE IF EXISTS `overduerules`; CREATE TABLE `overduerules` ( `overduerules_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the overduerules', `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'foreign key from the branches table to define which branch this rule is for (if blank it''s all libraries)', - `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'foreign key from the categories table to define which patron category this rule is for', + `categorycode` varchar(10) COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'foreign key from the categories table to define which patron category this rule is for', `delay1` int(4) DEFAULT NULL COMMENT 'number of days after the item is overdue that the first notice is sent', `letter1` varchar(20) DEFAULT NULL COMMENT 'foreign key from the letter table to define which notice should be sent as the first notice', `debarred1` varchar(1) DEFAULT '0' COMMENT 'is the patron restricted when the first notice is sent (1 for yes, 0 for no)', diff --git a/t/db_dependent/Overdues.t b/t/db_dependent/Overdues.t index 18236f2..8faa056 100755 --- a/t/db_dependent/Overdues.t +++ b/t/db_dependent/Overdues.t @@ -103,7 +103,7 @@ $dbh->do(q| INSERT INTO overduerules ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) VALUES - ( '', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) + ( NULL, NULL, 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |); my @branchcodes = map { $_->branchcode } Koha::Libraries->search->as_list; @@ -115,7 +115,7 @@ $dbh->do(q| INSERT INTO overduerules ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) VALUES - ( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) + ( 'CPL', NULL, 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |); @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); @@ -126,7 +126,7 @@ $dbh->do(q| INSERT INTO overduerules ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) VALUES - ( 'CPL', '', 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) + ( 'CPL', NULL, 1, 'LETTER_CODE1', 1, 5, 'LETTER_CODE2', 1, 10, 'LETTER_CODE3', 1 ) |); @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); @@ -137,8 +137,8 @@ $dbh->do(q| INSERT INTO overduerules ( branchcode,categorycode, delay1,letter1,debarred1, delay2,letter2,debarred2, delay3,letter3,debarred3 ) VALUES - ( 'CPL', '', 1, 'LETTER_CODE1_CPL', 1, 5, 'LETTER_CODE2_CPL', 1, 10, 'LETTER_CODE3_CPL', 1 ), - ( 'MPL', '', 1, 'LETTER_CODE1_MPL', 1, 5, 'LETTER_CODE2_MPL', 1, 10, 'LETTER_CODE3_MPL', 1 ) + ( 'CPL', NULL, 1, 'LETTER_CODE1_CPL', 1, 5, 'LETTER_CODE2_CPL', 1, 10, 'LETTER_CODE3_CPL', 1 ), + ( 'MPL', NULL, 1, 'LETTER_CODE1_MPL', 1, 5, 'LETTER_CODE2_MPL', 1, 10, 'LETTER_CODE3_MPL', 1 ) |); @overdue_branches = C4::Overdues::GetBranchcodesWithOverdueRules(); -- 2.43.0