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, ".")
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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{}{
|
||||||
|
|
Loading…
Reference in New Issue