Bug 24615 - Add support for ordering by related object columns in the REST API
Summary: Add support for ordering by related object columns in the REST API
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Agustín Moyano
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on: 24502
Blocks: 24561
  Show dependency treegraph
 
Reported: 2020-02-07 22:15 UTC by Agustín Moyano
Modified: 2020-11-30 21:48 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.05.00


Attachments
Bug 24615: Make object.search helper also order by embedded columns (4.10 KB, patch)
2020-02-08 03:04 UTC, Agustín Moyano
Details | Diff | Splinter Review
Bug 24615: Make object.search helper also order by embedded columns (4.15 KB, patch)
2020-02-20 20:22 UTC, David Nind
Details | Diff | Splinter Review
Bug 24615: Make object.search helper also order by embedded columns (4.21 KB, patch)
2020-02-21 07:23 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Agustín Moyano 2020-02-07 22:15:55 UTC
Make object.search helper be able to order by prefetched columns
Comment 1 Agustín Moyano 2020-02-08 03:04:10 UTC
Created attachment 98604 [details] [review]
Bug 24615: Make object.search helper also order by embedded columns

With this patch REST API request can order results by embedded columns.

Full path to the column must be given for it to work.
For example: If you are on biblio endpoint and you want to order by holding patron's card number you could

> GET /biblio/1?_order_by=item.holds.cardnumber HTTP/1.1
> x-koha-embed: item.holds

To test:
1. apply this patch
2. prove t/db_dependent/Koha/REST/Plugin/Objects.t
Comment 2 David Nind 2020-02-10 08:02:03 UTC
Path doesn't apply:

.git/rebase-apply/patch:67: trailing whitespace.
    
warning: 1 line adds whitespace errors.
Using index info to reconstruct a base tree...
M	Koha/REST/Plugin/Query.pm
M	t/db_dependent/Koha/REST/Plugin/Objects.t
.git/rebase-apply/patch:67: trailing whitespace.
    
warning: 1 line applied after fixing whitespace errors.
Comment 3 Agustín Moyano 2020-02-19 14:18:42 UTC
Dependency 24502 was in Failed QA state.

Patches now apply.
Comment 4 David Nind 2020-02-20 20:22:24 UTC
Created attachment 99338 [details] [review]
Bug 24615: Make object.search helper also order by embedded columns

With this patch REST API request can order results by embedded columns.

Full path to the column must be given for it to work.
For example: If you are on biblio endpoint and you want to order by holding patron's card number you could

> GET /biblio/1?_order_by=item.holds.cardnumber HTTP/1.1
> x-koha-embed: item.holds

To test:
1. apply this patch
2. prove t/db_dependent/Koha/REST/Plugin/Objects.t

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 Martin Renvoize 2020-02-21 07:23:51 UTC
Created attachment 99353 [details] [review]
Bug 24615: Make object.search helper also order by embedded columns

With this patch REST API request can order results by embedded columns.

Full path to the column must be given for it to work.
For example: If you are on biblio endpoint and you want to order by holding patron's card number you could

> GET /biblio/1?_order_by=item.holds.cardnumber HTTP/1.1
> x-koha-embed: item.holds

To test:
1. apply this patch
2. prove t/db_dependent/Koha/REST/Plugin/Objects.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Martin Renvoize 2020-02-21 07:24:13 UTC
Clear patch and no QA failures.

Passing QA
Comment 7 Martin Renvoize 2020-03-03 09:23:11 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 8 Joy Nelson 2020-04-01 21:12:10 UTC
enhancement not backported to 19.11.x