Skip to content

Commit

Permalink
Merge pull request #3257 from fatih/fix-nil-setting-schema
Browse files Browse the repository at this point in the history
schema: delete non existing values
  • Loading branch information
phinze committed Dec 9, 2015
2 parents 3041920 + f269d4f commit edaf579
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit edaf579

Please sign in to comment.