Skip to content

delete_values() fix bug #20681. #182

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

Merged
merged 1 commit into from
Sep 17, 2013

Conversation

lmello
Copy link
Contributor

@lmello lmello commented Sep 16, 2013

(#20681) fix behaviour of delete_values

The issue #20681 describe the error of delete() function
removing the elements from the origin array/hash/string.

This issue affected other delete functions. Because
ruby delete and delete_if functions make destructive
changes to the origin array/hash.

The delete_undef_values removed elements from the
origin hash and this is not the desired behaviour.

To solve this, we should dup or clone the hash
before using the delete or delete_if ruby functions.

This fix the problem and add unit tests, so we could
enforce this behaviour and prevent regressions.

@adrienthebo
Copy link
Contributor

Thank you very much for this contribution! This looks great, but before we merge this I would like the commit message to match our project conventions. Once that's addressed we can merge this in.

Housekeeping - Commit Message

It would be good to have the commit message amended a little. The first line of the commit should have the issue number and a description of the problem or fix, and the body of the commit message should explain what is this existing behavior and how this change fixes it. We have a more complete explanation of this at https://github.com/puppetlabs/puppet/blob/master/CONTRIBUTING.md#making-changes .

@lmello
Copy link
Contributor Author

lmello commented Sep 16, 2013

Thanks for the explanation. i will change that tomorrow! :-)

The issue #20681 describe the error of delete() function
removing the elements from the origin array/hash/string.

This issue affected other delete functions. Because
ruby delete and delete_if functions make destructive
changes to the origin array/hash.

The delete_undef_values removed elements from the
origin hash and this is not the desired behaviour.

To solve this, we should dup or clone the hash
before using the delete or delete_if ruby functions.

This fix the problem and add unit tests, so we could
enforce this behaviour and prevent regressions.
adrienthebo added a commit that referenced this pull request Sep 17, 2013
@adrienthebo adrienthebo merged commit 1011670 into puppetlabs:master Sep 17, 2013
@adrienthebo
Copy link
Contributor

summary: merged into master in 1011670; thanks for the contribution!

@lmello
Copy link
Contributor Author

lmello commented Sep 17, 2013

Thanks !

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

Successfully merging this pull request may close these issues.

3 participants