From 6becfa25a0ac1795226f5d5bd5d8acdf361da5f0 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Wed, 15 Jan 2020 20:12:19 -0300 Subject: [PATCH] Bug 24432: Use Koha::Objects->from_api_mapping instead of attributes_from_api to get the column name in Koha::REST::Plugins::Query->_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 --- 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.17.1