kohastructure says itemtypes.notforloan is "1 if the item is not for loan, 0 if the item is available for loan". It is also defined as smallint(6). Unlike items.notforloan it cannot be any other value than 0 or 1. I think this should be NOT NULL DEFAULT 0 and tinyint(1).
Created attachment 165483 [details] [review] Bug 36687: Update itemtpes.notforloan to not allow NULL values and change to tinyint(1)
Created attachment 165484 [details] [review] Bug 36687: Schema changes
Hi, I think you need to first set any NULL values to 0 before the ALTER TABLE. I got this error when manually setting some itemtypes.notforloan values to NULL before running your DBRev. ``` ERROR - {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Data truncated for column 'notforloan' at row 1 at /kohadevbox/koha/C4/Installer.pm line 741 ``` Also, I think the is_boolean flag should be added to the schema file.
Created attachment 165819 [details] [review] Bug 36687: Update itemtypes.notforloan to not allow NULL values and change to tinyint(1) To test: 1. Have some itemtypes.notforloan values set to NULL. 2. APPLY PACTH, updatedatabase, restart_all 3. When you updatedatabase those values should be set to 0. 4. Try updating an itemtypes.notforloan value to NULL. You cannot.
Created attachment 165820 [details] [review] Bug 36687: Schema updates
> Also, I think the is_boolean flag should be added to the schema file. Is it not already there? 343 '+notforloan' => { is_boolean => 1 },
Created attachment 165840 [details] [review] Bug 36687: Update itemtypes.notforloan to not allow NULL values and change to tinyint(1) To test: 1. Have some itemtypes.notforloan values set to NULL. 2. APPLY PACTH, updatedatabase, restart_all 3. When you updatedatabase those values should be set to 0. 4. Try updating an itemtypes.notforloan value to NULL. You cannot. Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Created attachment 165841 [details] [review] Bug 36687: Schema updates Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
(In reply to Lucas Gass from comment #0) > kohastructure says itemtypes.notforloan is "1 if the item is not for loan, 0 > if the item is available for loan". It is also defined as smallint(6). > > Unlike items.notforloan it cannot be any other value than 0 or 1. > > I think this should be NOT NULL DEFAULT 0 and tinyint(1). Seems wrong to me. We have several notforloan values. Not only 0 and 1.
(In reply to Marcel de Rooy from comment #9) > (In reply to Lucas Gass from comment #0) > > kohastructure says itemtypes.notforloan is "1 if the item is not for loan, 0 > > if the item is available for loan". It is also defined as smallint(6). > > > > Unlike items.notforloan it cannot be any other value than 0 or 1. > > > > I think this should be NOT NULL DEFAULT 0 and tinyint(1). > > Seems wrong to me. We have several notforloan values. Not only 0 and 1. This is itemtypes.notforloan. Which can only be set to 0 or 1 in the UI. See the attachment I'm uploading.
Created attachment 166257 [details] The place it can be set
(In reply to Tomás Cohen Arazi from comment #10) > (In reply to Marcel de Rooy from comment #9) > > (In reply to Lucas Gass from comment #0) > > > kohastructure says itemtypes.notforloan is "1 if the item is not for loan, 0 > > > if the item is available for loan". It is also defined as smallint(6). > > > > > > Unlike items.notforloan it cannot be any other value than 0 or 1. > > > > > > I think this should be NOT NULL DEFAULT 0 and tinyint(1). > > > > Seems wrong to me. We have several notforloan values. Not only 0 and 1. > > This is itemtypes.notforloan. Which can only be set to 0 or 1 in the UI. > See the attachment I'm uploading. Ok Where are my glasses :)
(In reply to Marcel de Rooy from comment #12) > (In reply to Tomás Cohen Arazi from comment #10) > > (In reply to Marcel de Rooy from comment #9) > > > (In reply to Lucas Gass from comment #0) > > > > kohastructure says itemtypes.notforloan is "1 if the item is not for loan, 0 > > > > if the item is available for loan". It is also defined as smallint(6). > > > > > > > > Unlike items.notforloan it cannot be any other value than 0 or 1. > > > > > > > > I think this should be NOT NULL DEFAULT 0 and tinyint(1). > > > > > > Seems wrong to me. We have several notforloan values. Not only 0 and 1. > > > > This is itemtypes.notforloan. Which can only be set to 0 or 1 in the UI. > > See the attachment I'm uploading. > > Ok Where are my glasses :) Ah the description mentioned items..
Created attachment 166413 [details] [review] Bug 36687: Update itemtypes.notforloan to not allow NULL values and change to tinyint(1) To test: 1. Have some itemtypes.notforloan values set to NULL. 2. APPLY PACTH, updatedatabase, restart_all 3. When you updatedatabase those values should be set to 0. 4. Try updating an itemtypes.notforloan value to NULL. You cannot. Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 166414 [details] [review] [DO NOT PUSH] Bug 36687: Schema updates Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Thanks Tomas.
Pushed for 24.05! Well done everyone, thank you!
Created attachment 166447 [details] [review] Bug 36687: (RM follow-up) Fix unit tests Set notforloan to '0' as apposed to 'undef' for tests Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Created attachment 166448 [details] [review] Bug 36687: (RM follow-up) Fix more unit tests Use currency.active to test `int(1) DEFAULT NULL` now that itemtypes.notforloan is `NOT NULL DEFAULT '0'` Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Follow-ups Pushed as RM backup.
Pushed to 23.11.x for 23.11.06
Enhancement will not be backported to 23.05.x