From aad285e28598f7d037af810d7d471e6a7539c20f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 12 Jul 2024 10:15:44 +0100 Subject: [PATCH] Bug 36641: Return '*' for 'default rule' Signed-off-by: Tomas Cohen Arazi --- Koha/REST/V1/CirculationRules.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Koha/REST/V1/CirculationRules.pm b/Koha/REST/V1/CirculationRules.pm index 05fe52c2999..81e5c93f1ce 100644 --- a/Koha/REST/V1/CirculationRules.pm +++ b/Koha/REST/V1/CirculationRules.pm @@ -51,11 +51,11 @@ sub list_rules { return try { my $effective = $c->param('effective') // 1; - my $kinds = $c->param('rules') // [ keys %{ Koha::CirculationRules->rule_kinds } ]; + my $kinds = $c->param('rules') // [ keys %{ Koha::CirculationRules->rule_kinds } ]; my $item_type = $c->param('item_type_id'); my $branchcode = $c->param('library_id'); my $patron_category = $c->param('patron_category_id'); - my ($filter_branch, $filter_itemtype, $filter_patron); + my ( $filter_branch, $filter_itemtype, $filter_patron ); if ($item_type) { $filter_itemtype = 1; @@ -124,8 +124,12 @@ sub list_rules { ) // {}; push @{$rules}, $effective_rules; } else { - my $select = [ 'branchcode', 'categorycode', 'itemtype' ]; - my $as = [ 'branchcode', 'categorycode', 'itemtype' ]; + my $select = [ + { 'COALESCE' => [ 'branchcode', \["'*'"] ], -as => 'branchcode' }, + { 'COALESCE' => [ 'categorycode', \["'*'"] ], -as => 'categorycode' }, + { 'COALESCE' => [ 'itemtype', \["'*'"] ], -as => 'itemtype' } + ]; + my $as = [ 'branchcode', 'categorycode', 'itemtype' ]; for my $kind ( @{$kinds} ) { push @{$select}, { max => \[ "CASE WHEN rule_name = ? THEN rule_value END", $kind ], -as => $kind }; push @{$as}, $kind; -- 2.45.2