Bugzilla – Attachment 169398 Details for
Bug 18086
overduerules table is lacking foreign key constraints
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18086: Fix issues with NULL for branches
Bug-18086-Fix-issues-with-NULL-for-branches.patch (text/plain), 2.94 KB, created by
Baptiste Wojtkowski (bwoj)
on 2024-07-23 09:38:23 UTC
(
hide
)
Description:
Bug 18086: Fix issues with NULL for branches
Filename:
MIME Type:
Creator:
Baptiste Wojtkowski (bwoj)
Created:
2024-07-23 09:38:23 UTC
Size:
2.94 KB
patch
obsolete
>From 24f3a5031d81bf8c468b5c13a6a29d78a43ca10c Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <bski@laposte.net> >Date: Thu, 11 Jul 2024 12:13:01 +0200 >Subject: [PATCH] Bug 18086: Fix issues with NULL for branches > >See https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18086#c27 >for more context : >This addresses the third point of this comment. > >A few tests do not pass because they test the behaviour of functions concerning branches on an empty string, which is now forbidden due to the foreign key constraint. >I propose changes for branches and for categories in two different patches, changing the behaviour of functions so that they interprete NULL in db as the default rule. >--- > C4/Overdues.pm | 5 +++++ > t/db_dependent/Overdues.t | 22 ++++++++++++++++++++-- > 2 files changed, 25 insertions(+), 2 deletions(-) > >diff --git a/C4/Overdues.pm b/C4/Overdues.pm >index 7200b88..115df38 100644 >--- a/C4/Overdues.pm >+++ b/C4/Overdues.pm >@@ -684,6 +684,10 @@ sub GetBranchcodesWithOverdueRules { > WHERE delay1 IS NOT NULL > ORDER BY branchcode > |); >+ unless ( $branchcodes->[0] ) { >+ my $default_rule = Koha::OverdueRules->search({ branchcode => undef }, {})->next; >+ return Koha::Libraries->search({}, { order_by => 'branchname' })->get_column('branchcode'); >+ } > if ( defined $branchcodes->[0] && $branchcodes->[0] eq '' ) { > # If a default rule exists, all branches should be returned > return Koha::Libraries->search({}, { order_by => 'branchname' })->get_column('branchcode'); >@@ -766,6 +770,7 @@ sub GetOverduesForBranch { > sub GetOverdueMessageTransportTypes { > my ( $branchcode, $categorycode, $letternumber ) = @_; > return unless $categorycode and $letternumber; >+ $branchcode = undef if ($branchcode eq ''); > my $rule = Koha::OverdueRules->search( > { > branchcode => $branchcode, >diff --git a/t/db_dependent/Overdues.t b/t/db_dependent/Overdues.t >index af719fa..599ceec 100755 >--- a/t/db_dependent/Overdues.t >+++ b/t/db_dependent/Overdues.t >@@ -26,17 +26,35 @@ $dbh->do(q|DELETE FROM message_queue|); > $dbh->do(q|DELETE FROM message_transport_types|); > $dbh->do(q|DELETE FROM overduerules|); > $dbh->do(q|DELETE FROM overduerules_transport_types|); >+$dbh->do(q|DELETE FROM branches|); >+ > > $dbh->do(q| > INSERT INTO message_transport_types( message_transport_type ) VALUES ('email'), ('phone'), ('print'), ('sms') > |); > >+$builder->build({ >+ source => 'Branch', >+ value => { >+ branchcode => 'CPL' >+ } >+}); >+ >+$builder->build({ >+ source => 'Branch', >+ value => { >+ branchcode => 'MPL' >+ } >+}); >+ >+ >+ > $dbh->do(q| > INSERT INTO overduerules ( overduerules_id, branchcode, categorycode ) VALUES > (1, 'CPL', 'PT'), > (2, 'CPL', 'YA'), >- (3, '', 'PT'), >- (4, '', 'YA') >+ (3, NULL, 'PT'), >+ (4, NULL, 'YA') > |); > > $dbh->do(q|INSERT INTO overduerules_transport_types (overduerules_id, letternumber, message_transport_type) VALUES >-- >2.43.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18086
:
105368
|
105369
|
105380
|
105382
|
105387
|
105388
|
105424
|
105551
|
106201
|
134730
|
134731
|
168810
|
168811
|
168812
|
168813
|
168814
|
168815
|
169287
|
169288
|
169289
|
169290
|
169291
|
169292
|
169293
|
169294
|
169295
|
169296
|
169297
|
169298
|
169299
|
169300
|
169301
|
169302
|
169396
|
169397
|
169398
|
169399
|
169400
|
169401
|
169402
|
169403
|
169404
|
169455
|
169456
|
169457
|
169458
|
169459
|
169460
|
169461
|
169462
|
169463
|
169543
|
169544