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

Deep merge fix #7

Merged
merged 4 commits into from Mar 21, 2024
Merged

Deep merge fix #7

merged 4 commits into from Mar 21, 2024

Conversation

ccooke
Copy link
Contributor

@ccooke ccooke commented Mar 20, 2024

Pull Request (PR) description

The deep_merge gem has a longstanding issue where using the deep_merge method will never replace a true value with false. The deep_merge! method does have the expected behaviour, and the code in this module already creates a duplicate object for the destination object, so the fix is simple.

This Pull Request (PR) fixes the following issues

n/a

`deep_merge` has a bug that prevents it replacing a true value
with false in certain circumstances. Fixed.
@ccooke ccooke added the bug Something isn't working label Mar 20, 2024
@@ -340,7 +340,7 @@ def basic_structure(title, file: true)
owner: 'root',
group: 'root',
mode: '0644',
content: "---\nlist:\n- 1\n- 2\nhash:\n one: 1\n two: 2\nrepl:\n not_two: 7\n"
content: "---\nlist:\n- 1\n- 2\nhash:\n one: 3\n two: 2\nrepl:\n not_two: 2\n"
Copy link
Contributor

@zilchms zilchms Mar 20, 2024

Choose a reason for hiding this comment

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

I think for better readability this whole is_expected test-block should be rewritten a bit. An expected output of not_two: 2 is a bit confusing.
I am guessing we can easily do that by switching around the order of the hashes (or renaming some keys)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. This was a cobbled together functional test at 2am. I believe I've actually replicated everything it covers with proper tests, so now's a good time to remove it.
What I should to though is add a test for the specific issue in this PR.

Copy link
Member

@Valantin Valantin left a comment

Choose a reason for hiding this comment

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

Probably need documentation and a parameter to use different deep_merge! overwrite option

@ccooke
Copy link
Contributor Author

ccooke commented Mar 21, 2024

Probably need documentation and a parameter to use different deep_merge! overwrite option

Hmm. I think that's more of an alternate feature - the behaviour in this patch is what's described in the documentation. I'll implement it if there's a request for it, but otherwise I think this is good.

@ccooke ccooke merged commit f695add into voxpupuli:main Mar 21, 2024
4 checks passed
@ccooke ccooke deleted the deep_merge_fix branch March 25, 2024 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants