From 8754e100f4f1238e75ff2df62194a9c99dd3f48d 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 Signed-off-by: Katrin Fischer --- 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 05fe52c299..81e5c93f1c 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.39.5