Bugzilla – Attachment 130309 Details for
Bug 29570
Unable to sort summary column of pending_orders table on parcel.pl by summary column
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29570: Fix sorting orders by biblioitems columns
Bug-29570-Fix-sorting-orders-by-biblioitems-column.patch (text/plain), 2.25 KB, created by
Jonathan Druart
on 2022-02-08 16:36:00 UTC
(
hide
)
Description:
Bug 29570: Fix sorting orders by biblioitems columns
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-02-08 16:36:00 UTC
Size:
2.25 KB
patch
obsolete
>From d5c3cbf44c2cd4cc61f3dfcb90872c046ed1182f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 2 Feb 2022 17:04:08 -0300 >Subject: [PATCH] Bug 29570: Fix sorting orders by biblioitems columns > >The API representation of Koha::Biblio objects includes the >biblioitems.* columns too. This proved problematic as queries had to get >translated so they work (i.e. if a query passes q={"biblio.ean":"123%"} >then the query needs to be tweaked so biblio.ean is translated into >biblio.biblioitem.ean. This is solved, locally, in the controller. > >But sorting needs the same kind of tweak, and it was missing. This patch >solves that by doing a similar conversion. > >To test: >1. Apply the regression tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/acquisitions_orders.t >=> FAIL: Tests fail, searching on a 'biblioitems' column generates a 500 >error. >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! We can sort on those fields >5. Sign off :-D > >Note: you will notice the tests only cover sorting by ISBN. I consider >it enough as sorting is a DB problem, and we only want to know if the >generated ORDER BY is valid for the underlying query, and MySQL would >complain if it wasn't the case. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/REST/V1/Acquisitions/Orders.pm | 8 ++++++++ > 1 file changed, 8 insertions(+) > >diff --git a/Koha/REST/V1/Acquisitions/Orders.pm b/Koha/REST/V1/Acquisitions/Orders.pm >index d3a7033d2de..03851a6d96b 100644 >--- a/Koha/REST/V1/Acquisitions/Orders.pm >+++ b/Koha/REST/V1/Acquisitions/Orders.pm >@@ -75,6 +75,14 @@ sub list { > $c->stash('koha.embed', $fixed_embed); > } > >+ if ( exists $reserved_params->{_order_by} ) { >+ # _order_by passed, fix if required >+ for ( my $i = 0; $i < scalar @{$reserved_params->{_order_by}}; $i++ ) { >+ $reserved_params->{_order_by}->[$i] =~ s|biblio\.|biblio\.biblioitem\.|g >+ if $reserved_params->{_order_by}->[$i] =~ m/.*(isbn|ean|publisher).*/; >+ } >+ } >+ > # Merge sorting into query attributes > $c->dbic_merge_sorting( > { >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29570
:
130122
|
130123
|
130124
|
130125
|
130126
|
130127
|
130308
| 130309 |
130310
|
130311
|
130336