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

Fix Hash params renaming #1903

Merged
merged 1 commit into from
Aug 30, 2019

Conversation

bikolya
Copy link
Contributor

@bikolya bikolya commented Aug 30, 2019

Previously it wasn't possible to rename attributes that have a block: https://github.com/ruby-grape/grape/blob/master/lib/grape/dsl/parameters.rb#L134. Known side effects: renamed keys aren't removed from params and cause duplication there, but declared(params) keeps only the correct keys.

This PR doesn't fix the problem with duplication of keys in the params hash when a deeply nested attribute or an attribute with a block is renamed. Here we remove renamed keys https://github.com/ruby-grape/grape/blob/master/lib/grape/endpoint.rb#L327-L332, but the only place we mark keys for deletion is here: https://github.com/ruby-grape/grape/blob/master/lib/grape/validations/params_scope.rb#L128 and it doesn't cover the case of hash/array attributes with block or even ordinary nested attributes.

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, fix changelog and we're good to go. Thank you.

CHANGELOG.md Outdated Show resolved Hide resolved
@dblock dblock merged commit 5476b27 into ruby-grape:master Aug 30, 2019
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

Successfully merging this pull request may close these issues.

2 participants