Bugzilla – Attachment 69305 Details for
Bug 19370
Add a helper function for translating order_by params into SQL::Abstract
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19370: (QA followup) Use OpenAPI's handling of pipe separated values
Bug-19370-QA-followup-Use-OpenAPIs-handling-of-pip.patch (text/plain), 3.18 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-11-23 14:03:14 UTC
(
hide
)
Description:
Bug 19370: (QA followup) Use OpenAPI's handling of pipe separated values
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-11-23 14:03:14 UTC
Size:
3.18 KB
patch
obsolete
>From 0afb9c4cb485a74899e2e364160088c5d96b413e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 23 Nov 2017 10:45:59 -0300 >Subject: [PATCH] Bug 19370: (QA followup) Use OpenAPI's handling of pipe > separated values > >This patch makes the helper handling _order_by params expect a list of >values instead of a (to-be-splitted) string. > >The idea is that the OpenAPI plugin will take care of splitting >pipe-delimited values if the spec is correctly defined. > >Note: In the process I noticed + on the URL represents a space, so the >helper function is updated to handle both + and %2B as ascending. > >To test: >- Run: > $ kshell > k$ prove t/Koha/REST/Plugin/Query.t >=> SUCCESS: Tests pass! >- Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/Plugin/Query.pm | 7 ++++--- > t/Koha/REST/Plugin/Query.t | 16 +++++++++++----- > 2 files changed, 15 insertions(+), 8 deletions(-) > >diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm >index 77d2fadd6a..090f02fe0b 100644 >--- a/Koha/REST/Plugin/Query.pm >+++ b/Koha/REST/Plugin/Query.pm >@@ -83,7 +83,7 @@ Generates the DBIC order_by attributes based on I<$params>, and merges into I<$a > > if ( defined $args->{params}->{_order_by} ) { > my @order_by = map { _build_order_atom($_) } >- split( /\|/, $args->{params}->{_order_by} ); >+ @{ $args->{params}->{_order_by} }; > $attributes->{order_by} = \@order_by; > } > >@@ -167,9 +167,10 @@ according to the following rules: > sub _build_order_atom { > my $string = shift; > >- if ( $string =~ m/^\+/ ) { >+ if ( $string =~ m/^\+/ or >+ $string =~ m/^\s/ ) { > # asc order operator present >- $string =~ s/^\+//; >+ $string =~ s/^(\+|\s)//; > return { -asc => $string }; > } > elsif ( $string =~ m/^\-/ ) { >diff --git a/t/Koha/REST/Plugin/Query.t b/t/Koha/REST/Plugin/Query.t >index a4c6684ba5..cdcdb4ca92 100644 >--- a/t/Koha/REST/Plugin/Query.t >+++ b/t/Koha/REST/Plugin/Query.t >@@ -74,7 +74,7 @@ get '/dbic_merge_sorting' => sub { > $attributes = $c->dbic_merge_sorting( > { > attributes => $attributes, >- params => { _match => 'exact', _order_by => 'uno|-dos|+tres' } >+ params => { _match => 'exact', _order_by => [ 'uno', '-dos', '+tres', ' cuatro' ] } > } > ); > $c->render( json => $attributes, status => 200 ); >@@ -135,13 +135,19 @@ subtest 'dbic_merge_sorting() tests' => sub { > > my $t = Test::Mojo->new; > >- $t->get_ok('/dbic_merge_sorting') >- ->status_is(200) >+ $t->get_ok('/dbic_merge_sorting')->status_is(200) > ->json_is( '/a' => 'a', 'Existing values are kept (a)' ) >- ->json_is( '/b' => 'b', 'Existing values are kept (b)' ) >- ->json_is( '/order_by' => [ 'uno', { -desc => 'dos' }, { -asc => 'tres' } ] ); >+ ->json_is( '/b' => 'b', 'Existing values are kept (b)' )->json_is( >+ '/order_by' => [ >+ 'uno', >+ { -desc => 'dos' }, >+ { -asc => 'tres' }, >+ { -asc => 'cuatro' } >+ ] >+ ); > }; > >+ > subtest '_build_query_params_from_api' => sub { > > plan tests => 16; >-- >2.15.0
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 19370
:
67379
|
67380
|
67402
|
67403
|
67525
|
67576
|
67782
|
67783
|
67784
|
69304
|
69305
|
69307
|
69383
|
69384
|
69391
|
69392
|
69393
|
69394