Merge pull request #3257 from fatih/fix-nil-setting-schema

schema: delete non existing values
This commit is contained in:
Paul Hinze 2015-12-08 20:15:00 -06:00
commit edaf5795a5
2 changed files with 11 additions and 1 deletions

View File

@ -207,7 +207,8 @@ func (w *MapFieldWriter) setPrimitive(
k := strings.Join(addr, ".") k := strings.Join(addr, ".")
if v == nil { if v == nil {
delete(w.result, k) // The empty string here means the value is removed.
w.result[k] = ""
return nil return nil
} }

View File

@ -97,6 +97,15 @@ func TestMapFieldWriter(t *testing.T) {
}, },
}, },
"string nil": {
[]string{"string"},
nil,
false,
map[string]string{
"string": "",
},
},
"list of resources": { "list of resources": {
[]string{"listResource"}, []string{"listResource"},
[]interface{}{ []interface{}{