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

Allow decoding embedded struct pointer in decodeMapFromStruct #199

Closed
wants to merge 3 commits into from

Conversation

guscott
Copy link

@guscott guscott commented Jun 19, 2020

This may address #156 , but it is not my use case, so I did not validated this case particularly.

@mitchellh
Copy link
Owner

This looks good, but do you mind pulling this out into a separate standalone test case vs. overloading another? That makes it easier to remember what the test is addressing.

@guscott
Copy link
Author

guscott commented Jun 29, 2020

A new test case was added just for this.

@@ -2316,17 +2351,12 @@ func TestDecode_StructTaggedWithOmitempty_KeepNonEmptyValues(t *testing.T) {
VisibleMapField: nil,
OmitMapField: map[string]interface{}{"k": "v"},
NestedField: nil,
OmitNestedField: &Nested{},
OmitNestedField: nil,
Copy link

Choose a reason for hiding this comment

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

Was this change intended? Looks a bit suspicious to me.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, this is intended. This PR change the behavior of struct pointer to allow decoding them. This means that &Nested{} is no longer considered nil once decoded; it will be a empty map[string]interface{}. Since this is not what is tested here, a separate unit test (TestNestedTypeStructPointer) was added just for this and this test was modified to pass nil so that it is not overloaded.

@mitchellh
Copy link
Owner

Fixed by #205

@mitchellh mitchellh closed this Nov 26, 2020
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.

None yet

3 participants