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>
$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 };
}
subtest 'stash_embed() tests' => sub {
- plan tests => 14;
+ plan tests => 16;
my $t = Test::Mojo->new;
$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 => {} } },