Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested route_param loses params from parent route_param #77

Closed
mschout opened this issue Aug 26, 2019 · 4 comments
Closed

Nested route_param loses params from parent route_param #77

mschout opened this issue Aug 26, 2019 · 4 comments

Comments

@mschout
Copy link
Contributor

mschout commented Aug 26, 2019

We ran into this problem today. Seems that using route_param inside another route_param loses the params for the parent route_param.

Here is a test case demonstrating the problem:

subtest 'params nested route_param' => sub {
    resource api => sub {
        params requires => { name => 'id', type => undef };
        route_param id => sub {
            params(
                requires => { name => 'start', type => undef },
                optional => { name => 'count', type => undef },
            );
            get sub { param };

            params(
                requires => { name => 'sub_id', type => undef },
            );
            route_param sub_id => sub {
                get sub { param };
            };
        }
    };

    my $app = Raisin::API->app;
    my $e = $app->routes->routes->[1];

    my %params = map { $_->name => $_ } @{ $e->params };

    ok $params{id}, 'id';
    is $params{id}->named, 1, 'named';
    is $params{id}->required, 1, 'required';

    ok $params{sub_id}, 'sub_id';
    is $params{sub_id}->named, 1, 'named';
    is $params{sub_id}->required, 1, 'required';
};

What actually ends up in %params is only the sub_id param. The id param is lost.

@khrt
Copy link
Owner

khrt commented Aug 27, 2019

Thank you for providing a test scenario. Will take a look!

khrt pushed a commit that referenced this issue Aug 30, 2019
khrt pushed a commit that referenced this issue Sep 14, 2019
khrt pushed a commit that referenced this issue Sep 14, 2019
khrt pushed a commit that referenced this issue Sep 14, 2019
@khrt khrt closed this as completed in 06d50a9 Sep 14, 2019
@khrt
Copy link
Owner

khrt commented Sep 14, 2019

This must be fixed, but would be nice if you can verify that.

@mschout
Copy link
Contributor Author

mschout commented Sep 18, 2019

Thanks @khrt I will git it a spin today and let you know.

@mschout
Copy link
Contributor Author

mschout commented Sep 18, 2019

Working perfectly with v0.87, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants