From efd2dfdaae0441c4e8701278853e7a75db285717 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 | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 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 4e9c88c4ba..ccd6a0a518 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 @@ -1,5 +1,4 @@ use Modern::Perl; -use Koha::Holds; return { bug_number => "31086", @@ -8,11 +7,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.39.2