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

schema: delete non existing values #3257

Merged
merged 2 commits into from
Dec 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion helper/schema/field_writer_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ func (w *MapFieldWriter) setPrimitive(
k := strings.Join(addr, ".")

if v == nil {
delete(w.result, k)
// The empty string here means the value is removed.
w.result[k] = ""
return nil
}

Expand Down
9 changes: 9 additions & 0 deletions helper/schema/field_writer_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ func TestMapFieldWriter(t *testing.T) {
},
},

"string nil": {
[]string{"string"},
nil,
false,
map[string]string{
"string": "",
},
},

"list of resources": {
[]string{"listResource"},
[]interface{}{
Expand Down