diff --git a/helper/schema/field_writer_map.go b/helper/schema/field_writer_map.go index 7ef40b367..433ff7df6 100644 --- a/helper/schema/field_writer_map.go +++ b/helper/schema/field_writer_map.go @@ -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 } diff --git a/helper/schema/field_writer_map_test.go b/helper/schema/field_writer_map_test.go index 3f54f8303..783c7435f 100644 --- a/helper/schema/field_writer_map_test.go +++ b/helper/schema/field_writer_map_test.go @@ -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{}{