From 999b11e98a1bd9462796428648d818c9e60f2f3a Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 22 Jul 2022 14:36:39 -0300 Subject: [PATCH] Bug 31086: (QA follow-up) Use plain SQL in db_rev Signed-off-by: Tomas Cohen Arazi --- ...o_not_allow_null_branchcode_in_reserves.pl | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl b/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl index 4e9c88c4baa..dd6df1f9a5d 100755 --- a/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl +++ b/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl @@ -8,11 +8,22 @@ return { my ($args) = @_; my ($dbh, $out) = @$args{qw(dbh out)}; - my $holds_no_branch = Koha::Holds->search({ branchcode => undef }); - if( $holds_no_branch->count > 0 ){ + my $sth = $dbh->prepare(q{ + SELECT borrowernumber, biblionumber + FROM reserves + WHERE branchcode IS NULL; + }); + $sth->execute; + my $holds_no_branch = $sth->fetchall_arrayref( {} ); + + if ( scalar @{$holds_no_branch} > 0 ) { say $out "Holds with no branchcode were found and will be updated to the first branch in the system"; - while ( my $hnb = $holds_no_branch->next ){ - say $out "Please review hold for borrowernumber " . $hnb->borrowernumber . " on biblionumber " . $hnb->biblionumber . " to correct pickup branch if necessary"; + foreach my $hnb ( @{$holds_no_branch} ) { + say $out "Please review hold for borrowernumber " + . $hnb->{borrowernumber} + . " on biblionumber " + . $hnb->{biblionumber} + . " to correct pickup branch if necessary"; } } -- 2.34.1