Bug 40337

Summary: checkprevcheckout must be defined as ENUM at DB level
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: Pushed to stable --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: lucas, m.de.rooy
Version: unspecified   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.05.02
Circulation function:
Bug Depends on: 40178, 40179    
Bug Blocks:    
Attachments: Bug 40337: Define checkprevcheckout as ENUM
Bug 40337: DBIC schema changes
Bug 40337: DBIC schema changes
Bug 40337: Define checkprevcheckout as ENUM
Bug 40337: DBIC schema changes
Bug 40337: Handle enum in Koha::Patron->anonymize
Bug 40337: Do not set checkprevcheckout to an empty string when importing patrons

Description Jonathan Druart 2025-07-10 07:06:46 UTC
They are VARCHAR(7) but they must be enum('yes', 'no', 'inherit')
Comment 1 Jonathan Druart 2025-07-10 07:17:06 UTC
Created attachment 183918 [details] [review]
Bug 40337: Define checkprevcheckout as ENUM

On bug 40178 and bug 40179 we defined checkprevcheckout attributes as
ENUM at the REST API level, so the specs prevent us from inserting
values that are no yes, no, inherit in DB.
However the DB schema didn't have that constraint.
This has been caught by some tests that were failing:
eg. t/db_dependent/selenium/patrons_search.t with "Not in enum list: yes, no, inherit."

Test plan:
Apply this patch, run `updatedatabase`, `dbic` and `restart_all`
`prove t/db_dependent/selenium/patrons_search.t` should now pass.
Comment 2 Jonathan Druart 2025-07-10 07:17:09 UTC
Created attachment 183919 [details] [review]
Bug 40337: DBIC schema changes
Comment 3 Eric Garcia 2025-07-10 14:52:03 UTC
Created attachment 183946 [details] [review]
Bug 40337: DBIC schema changes

Signed-off-by: Eric Garcia <cubingguy714@gmail.com>
Comment 4 Lucas Gass (lukeg) 2025-07-10 15:42:24 UTC
Created attachment 183947 [details] [review]
Bug 40337: Define checkprevcheckout as ENUM

On bug 40178 and bug 40179 we defined checkprevcheckout attributes as
ENUM at the REST API level, so the specs prevent us from inserting
values that are no yes, no, inherit in DB.
However the DB schema didn't have that constraint.
This has been caught by some tests that were failing:
eg. t/db_dependent/selenium/patrons_search.t with "Not in enum list: yes, no, inherit."

Test plan:
Apply this patch, run `updatedatabase`, `dbic` and `restart_all`
`prove t/db_dependent/selenium/patrons_search.t` should now pass.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 5 Lucas Gass (lukeg) 2025-07-10 15:42:27 UTC
Created attachment 183948 [details] [review]
Bug 40337: DBIC schema changes

Signed-off-by: Eric Garcia <cubingguy714@gmail.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 6 Lucas Gass (lukeg) 2025-07-10 15:46:07 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 7 Jonathan Druart 2025-07-10 19:56:56 UTC
Created attachment 183969 [details] [review]
Bug 40337: Handle enum in Koha::Patron->anonymize

We need to reset to the default value. We might have a problem (later)
if it's NOT NULL and no default is set, which is not handled by this
patch. But the situation does not seem to exist yet anyway.
Comment 8 Jonathan Druart 2025-07-10 19:56:58 UTC
Created attachment 183970 [details] [review]
Bug 40337: Do not set checkprevcheckout to an empty string when importing patrons

We must remove it so that it will be set as the default value defined
at the DBMS level
Comment 9 Paul Derscheid 2025-07-10 20:51:18 UTC
Nice work everyone!

Pushed to 25.05.x
Comment 10 Lucas Gass (lukeg) 2025-07-10 23:34:58 UTC
follow-ups pushed to main
Comment 11 Marcel de Rooy 2025-07-15 11:55:34 UTC
+-------------------+
| checkprevcheckout |
+-------------------+
| inherit           |
| bpe8              |
| MIbcjV            |
| ngYcotJ           |
| z85xcQ_           |
| I523              |
| zqw1P             |
| koirKi            |
| ErwNnJ            |
+-------------------+

Stuff from tests? Causing:
        ERROR: {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Data truncated for column 'checkprevcheckout' at row 54 at /usr/share/koha/C4/Installer.pm line 825
Comment 12 Jonathan Druart 2025-07-15 12:17:24 UTC
(In reply to Marcel de Rooy from comment #11)
> +-------------------+
> | checkprevcheckout |
> +-------------------+
> | inherit           |
> | bpe8              |
> | MIbcjV            |
> | ngYcotJ           |
> | z85xcQ_           |
> | I523              |
> | zqw1P             |
> | koirKi            |
> | ErwNnJ            |
> +-------------------+
> 
> Stuff from tests? Causing:
>         ERROR: {UNKNOWN}: DBI Exception: DBD::mysql::db do failed: Data
> truncated for column 'checkprevcheckout' at row 54 at
> /usr/share/koha/C4/Installer.pm line 825

This happens if you have run some tests before the DB changes. Then the REST API will explode because it will send strings that do not match the ENUM values.