[Koha-bugs] [Bug 19370] Add a helper function for translating order_by params into SQL ::Abstract

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon Nov 27 17:46:19 CET 2017


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

--- Comment #18 from Kyle M Hall <kyle at bywatersolutions.com> ---
Created attachment 69392
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=69392&action=edit
Bug 19370: Add helper function for order_by attribute generation

This patch introduces a helper function called 'dbic_merge_sorting'
to Koha::REST::Plugin::Query.

This simple function adds SQL::Abstract order_by attribute to the passed
$filter hashref, as explained in the POD.

It introduces a syntax for passing sorting params on the request to the REST
api.
The proposed syntax has been found in the wild, and is pretty trivial to
parse/work with:

    GET /api/v1/<endpoint>?order_by=+column_1|-column_2|column_3

As explained on the POD, + stands for 'asc' and - for 'desc'. If ommited, it
defaults to the
DB engine default (usually asc).

To test:
- Apply this patches
- Run:
  $ sudo koha-shell kohadev
 k$ cd kohaclone
 k$ prove t/Koha/REST/Plugin/Query.t
=> SUCCESS: Tests pass! And they make sense! :-P
- Sign off :-D

Edit: renamed params to match DBIC terminology. My bad :-D (tcohen)

Sponsored-by: Camden County

Signed-off-by: Lari Taskula <lari.taskula at jns.fi>

Signed-off-by: Kyle M Hall <kyle at bywatersolutions.com>

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list