From cf11f3863dc528c3ec58aaaf37c6f85978ecac45 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 4 Nov 2025 15:48:32 +0000 Subject: [PATCH] Bug 37893: (QA follow-up): Insert defaults to database for delimiter and terminator Not considering here encoding here as I'm uncertain from the code if it should utf8 or ascii Signed-off-by: Lucas Gass --- Koha/Schema/Result/SipAccount.pm | 13 ++++++++----- installer/data/mysql/atomicupdate/bug_37893.pl | 8 ++++---- installer/data/mysql/kohastructure.sql | 4 ++-- t/db_dependent/Koha/SIP2/SIP2ModuleMigration.t | 13 ++++++++++++- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Koha/Schema/Result/SipAccount.pm b/Koha/Schema/Result/SipAccount.pm index 7a3cd05e68..8f8e3ece72 100644 --- a/Koha/Schema/Result/SipAccount.pm +++ b/Koha/Schema/Result/SipAccount.pm @@ -112,6 +112,7 @@ Foreign key to sip_institutions.sip_institution_id =head2 delimiter data_type: 'varchar' + default_value: '|' is_nullable: 1 size: 10 @@ -241,8 +242,9 @@ Foreign key to cash_registers.id =head2 terminator data_type: 'enum' + default_value: 'CRLF' extra: {list => ["CR","CRLF"]} - is_nullable: 1 + is_nullable: 0 =cut @@ -278,7 +280,7 @@ __PACKAGE__->add_columns( "da_field_template", { data_type => "varchar", is_nullable => 1, size => 255 }, "delimiter", - { data_type => "varchar", is_nullable => 1, size => 10 }, + { data_type => "varchar", default_value => "|", is_nullable => 1, size => 10 }, "disallow_overpayment", { data_type => "tinyint", is_nullable => 1 }, "encoding", @@ -324,8 +326,9 @@ __PACKAGE__->add_columns( "terminator", { data_type => "enum", + default_value => "CRLF", extra => { list => ["CR", "CRLF"] }, - is_nullable => 1, + is_nullable => 0, }, ); @@ -498,8 +501,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-10-24 14:53:53 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:unjLCC8L7SMwMe6xIcBgNA +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2025-11-04 15:47:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:N8uHee0eMqOcg0I1obuEWA __PACKAGE__->add_columns( diff --git a/installer/data/mysql/atomicupdate/bug_37893.pl b/installer/data/mysql/atomicupdate/bug_37893.pl index 2f14fcc9ee..d22d3eb64f 100755 --- a/installer/data/mysql/atomicupdate/bug_37893.pl +++ b/installer/data/mysql/atomicupdate/bug_37893.pl @@ -53,7 +53,7 @@ return { `cv_send_00_on_success` tinyint(1) NULL, `cv_triggers_alert` tinyint(1) NULL, `da_field_template` varchar(255) NULL, - `delimiter` varchar(10) NULL, + `delimiter` varchar(10) NULL DEFAULT '|', `disallow_overpayment` tinyint(1) NULL, `encoding` varchar(10) NULL, `error_detect` tinyint(1) NULL, @@ -75,7 +75,7 @@ return { `send_patron_home_library_in_af` tinyint(1) NULL, `show_checkin_message` tinyint(1) NULL, `show_outstanding_amount` tinyint(1) NULL, - `terminator` enum( 'CR', 'CRLF' ) NULL, + `terminator` enum('CR','CRLF') NOT NULL DEFAULT 'CRLF', PRIMARY KEY(`sip_account_id`), UNIQUE KEY `account_login_id` (`login_id`), KEY `sip_accounts_ibfk_1` (`sip_institution_id`), @@ -308,7 +308,7 @@ return { my $cv_send_00_on_success = $SIPconfig->{accounts}->{$account_key}->{cv_send_00_on_success}; my $cv_triggers_alert = $SIPconfig->{accounts}->{$account_key}->{cv_triggers_alert}; my $da_field_template = $SIPconfig->{accounts}->{$account_key}->{da_field_template}; - my $delimiter = $SIPconfig->{accounts}->{$account_key}->{delimiter} || undef; + my $delimiter = $SIPconfig->{accounts}->{$account_key}->{delimiter} || '|'; my $disallow_overpayment = $SIPconfig->{accounts}->{$account_key}->{disallow_overpayment}; my $encoding = $SIPconfig->{accounts}->{$account_key}->{encoding}; @@ -336,7 +336,7 @@ return { $SIPconfig->{accounts}->{$account_key}->{send_patron_home_library_in_af}; my $show_checkin_message = $SIPconfig->{accounts}->{$account_key}->{show_checkin_message}; my $show_outstanding_amount = $SIPconfig->{accounts}->{$account_key}->{show_outstanding_amount}; - my $terminator = $SIPconfig->{accounts}->{$account_key}->{terminator}; + my $terminator = $SIPconfig->{accounts}->{$account_key}->{terminator} || 'CRLF'; $insert_accounts->execute( $sip_institution_id, diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 7346e931a1..8ff9c060c0 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -6097,7 +6097,7 @@ CREATE TABLE `sip_accounts` ( `cv_send_00_on_success` tinyint(1) NULL, `cv_triggers_alert` tinyint(1) NULL, `da_field_template` varchar(255) NULL, - `delimiter` varchar(10) NULL, + `delimiter` varchar(10) NULL DEFAULT '|', `disallow_overpayment` tinyint(1) NULL, `encoding` varchar(10) NULL, `error_detect` tinyint(1) NULL, @@ -6119,7 +6119,7 @@ CREATE TABLE `sip_accounts` ( `send_patron_home_library_in_af` tinyint(1) NULL, `show_checkin_message` tinyint(1) NULL, `show_outstanding_amount` tinyint(1) NULL, - `terminator` enum('CR','CRLF') NULL, + `terminator` enum('CR','CRLF') NOT NULL DEFAULT 'CRLF', PRIMARY KEY (`sip_account_id`), UNIQUE KEY `account_login_id` (`login_id`), KEY `sip_accounts_ibfk_1` (`sip_institution_id`), diff --git a/t/db_dependent/Koha/SIP2/SIP2ModuleMigration.t b/t/db_dependent/Koha/SIP2/SIP2ModuleMigration.t index f43e5987d4..57d9fd6e77 100755 --- a/t/db_dependent/Koha/SIP2/SIP2ModuleMigration.t +++ b/t/db_dependent/Koha/SIP2/SIP2ModuleMigration.t @@ -59,14 +59,25 @@ subtest 'Config from XML matches config from database' => sub { delete $fileSIPconfig->{institutions}->{$key}{'parms'}; } - # Remove 'register_id' out of each account if it's empty. This can no longer be returned as an empty string as is now an FK constraint foreach my $key ( keys %{ $fileSIPconfig->{accounts} } ) { + + # Remove 'register_id' out of each account if it's empty. This can no longer be returned as an empty string as is now an FK constraint if ( defined $fileSIPconfig->{accounts}->{$key}{'register_id'} && $fileSIPconfig->{accounts}->{$key}{'register_id'} eq "" ) { delete $fileSIPconfig->{accounts}->{$key}{'register_id'}; } + # Remove terminator from file check as it's no longer nullable and defaults to 'CRLF' + if ( !$fileSIPconfig->{accounts}->{$key}{'terminator'} ) { + $fileSIPconfig->{accounts}->{$key}{'terminator'} = 'CRLF'; + } + + # Remove delimiter from file check as it now defaults to '|' + if ( !$fileSIPconfig->{accounts}->{$key}{'delimiter'} ) { + $fileSIPconfig->{accounts}->{$key}{'delimiter'} = '|'; + } + # Remove 'password' from file config as it's no longer migrated (security improvement) # Passwords are now validated against the borrowers table using bcrypt hashes delete $fileSIPconfig->{accounts}->{$key}{'password'};