From 6bef3c3c6987b8ebdc2820a9fdabfb5b34ba2b4b Mon Sep 17 00:00:00 2001 From: Andrew Fuerste-Henry Date: Sun, 26 Apr 2020 23:51:25 +0000 Subject: [PATCH] Bug 23081: set default to 0 for items.issues and deleteditems.issues To test: - save and run this sql query in reports: select sum(if(issues is null,1,0)),sum(if(issues=0,1,0)) from items - you should see a lot of nulls and no zeros - apply patch - updatedatabase - re-run your query and see that your nulls have changed to zeros - create a new item - rerun your query and see your new item is counted in the zeros, not the nulls Signed-off-by: Lucas Gass Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit 02896efdf347adbfa0cb262c9b7d46e11dbe4866) Signed-off-by: Lucas Gass --- Koha/Schema/Result/Deleteditem.pm | 8 ++++++-- Koha/Schema/Result/Item.pm | 8 ++++++-- installer/data/mysql/kohastructure.sql | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Koha/Schema/Result/Deleteditem.pm b/Koha/Schema/Result/Deleteditem.pm index 192017ff67..ad4d70966e 100644 --- a/Koha/Schema/Result/Deleteditem.pm +++ b/Koha/Schema/Result/Deleteditem.pm @@ -156,7 +156,8 @@ __PACKAGE__->table("deleteditems"); =head2 issues data_type: 'smallint' - is_nullable: 1 + is_nullable: 0 + default_value: 0 =head2 renewals @@ -341,7 +342,10 @@ __PACKAGE__->add_columns( "coded_location_qualifier", { data_type => "varchar", is_nullable => 1, size => 10 }, "issues", - { data_type => "smallint", is_nullable => 1 }, + { data_type => "smallint", + is_nullable => 0, + default_value => 0, + }, "renewals", { data_type => "smallint", is_nullable => 1 }, "reserves", diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index 71070c2b06..7ad0876020 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -159,7 +159,8 @@ __PACKAGE__->table("items"); =head2 issues data_type: 'smallint' - is_nullable: 1 + is_nullable: 0 + default_value: 0 =head2 renewals @@ -355,7 +356,10 @@ __PACKAGE__->add_columns( "coded_location_qualifier", { data_type => "varchar", is_nullable => 1, size => 10 }, "issues", - { data_type => "smallint", is_nullable => 1 }, + { data_type => "smallint", + is_nullable => 0, + default_value => 0, + }, "renewals", { data_type => "smallint", is_nullable => 1 }, "reserves", diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index b8ec78831a..13d47ae480 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -643,7 +643,7 @@ CREATE TABLE `deleteditems` ( `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o) `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f) - `issues` smallint(6) default NULL, -- number of times this item has been checked out + `issues` smallint(6) default 0, -- number of times this item has been checked out `renewals` smallint(6) default NULL, -- number of times this item has been renewed `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5) @@ -903,7 +903,7 @@ CREATE TABLE `items` ( -- holdings/item information `withdrawn_on` datetime DEFAULT NULL, -- the date and time an item was last marked as withdrawn, NULL if not withdrawn `itemcallnumber` varchar(255) default NULL, -- call number for this item (MARC21 952$o) `coded_location_qualifier` varchar(10) default NULL, -- coded location qualifier(MARC21 952$f) - `issues` smallint(6) default NULL, -- number of times this item has been checked out/issued + `issues` smallint(6) default 0, -- number of times this item has been checked out/issued `renewals` smallint(6) default NULL, -- number of times this item has been renewed `reserves` smallint(6) default NULL, -- number of times this item has been placed on hold/reserved `restricted` tinyint(1) default NULL, -- authorized value defining use restrictions for this item (MARC21 952$5) -- 2.39.5