Bug 32118: Add optional support for `:` as the modifier
This patch adds optional support for using `:` as the modifier for invoking the 'count' method for relations as discussed. We retain support for `+` for backward compatability to prevent a breaking change. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
12e3e91c13
commit
64d3498da4
|
|
@ -364,7 +364,7 @@ sub _parse_embed {
|
|||
$result->{$curr} = { children => _parse_embed( $next ) };
|
||||
}
|
||||
else {
|
||||
if ( $curr =~ m/^(?<relation>.*)\+count/ ) {
|
||||
if ( $curr =~ m/^(?<relation>.*)[\+|:]count/ ) {
|
||||
my $key = $+{relation} . "_count";
|
||||
$result->{$key} = { is_count => 1 };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ subtest '_build_query_params_from_api' => sub {
|
|||
|
||||
subtest 'stash_embed() tests' => sub {
|
||||
|
||||
plan tests => 14;
|
||||
plan tests => 16;
|
||||
|
||||
my $t = Test::Mojo->new;
|
||||
|
||||
|
|
@ -446,6 +446,9 @@ subtest 'stash_embed() tests' => sub {
|
|||
$t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'holds+count' } )
|
||||
->json_is( '/embed' => { holds_count => { is_count => 1 } } );
|
||||
|
||||
$t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'holds:count' } )
|
||||
->json_is( '/embed' => { holds_count => { is_count => 1 } } );
|
||||
|
||||
$t->get_ok( '/stash_embed' => { 'x-koha-embed' => 'checkouts,checkouts.item,patron' } )
|
||||
->json_is( '/embed' => {
|
||||
checkouts => { children => { item => {} } },
|
||||
|
|
|
|||
Loading…
Reference in New Issue