[Koha-bugs] [Bug 24432] New: Request an endpoint with a date column in order by throws bad parameter exception

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Wed Jan 15 22:39:06 CET 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432

            Bug ID: 24432
           Summary: Request an endpoint with a date column in order by
                    throws bad parameter exception
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P5 - low
         Component: REST API
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: agustinmoyano at theke.io
                CC: tomascohen at gmail.com
        Depends on: 23893
            Blocks: 20936

When you request an endpoint in the API with a date as orderby, it throws
Koha::Exceptions::BadParameter.

Koha::REST::Plugin::Query in _build_order_atom, in order to get the model
parameter for the order by, it requests 

{instance of Koha::Objects}->attributes_from_api({ <api parameter name> => 1
});

to get that hash translated, and use the resulting key as the model column to
do the order by.

This works ok for all datatypes except date types, because it's trying to
transate the value of "1" as a date, throwig the mentioned exception.

In my opinion, _build_order_atom should not use attributes_from_api, but should
use the mapping in Koha::Object to get the column name.


Referenced Bugs:

https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20936
[Bug 20936] Holds History for patrons in OPAC
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23893
[Bug 23893] Add ->new_from_api and ->set_from_api methods to Koha::Object
-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list