Merge pull request #3257 from fatih/fix-nil-setting-schema
schema: delete non existing values
This commit is contained in:
commit
edaf5795a5
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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{}{
|
||||
|
|
Loading…
Reference in New Issue