From 02513636b107d245a56e3f97785b6a421b61d5bb Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Wed, 15 Jan 2020 20:12:19 -0300 Subject: [PATCH] Bug 24432: Use from_api_mapping to translate column name in _build_order_atom Use the mapping instead of building a fake hash only to get the key name. To test: 1. apply this patch 2. prove t/Koha/REST/Plugin/Query.t 3. sign off Signed-off-by: Tomas Cohen Arazi --- Koha/REST/Plugin/Query.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm index 3317348a58..b2ebd8f77a 100644 --- a/Koha/REST/Plugin/Query.pm +++ b/Koha/REST/Plugin/Query.pm @@ -220,7 +220,8 @@ sub _build_order_atom { my $param = $string; $param =~ s/^(\+|\-|\s)//; if ( $result_set ) { - $param = (keys %{$result_set->attributes_from_api({ $param => 1 })})[0]; + my $model_param = $result_set->from_api_mapping->{$param}; + $param = $model_param if defined $model_param; } if ( $string =~ m/^\+/ or -- 2.25.0