1
0
mirror of https://github.com/rancher/norman.git synced 2025-08-01 15:28:11 +00:00

Changes to Mapper embed to insert nil value if applicable for a schema field

This commit is contained in:
Prachi Damle 2018-06-07 11:56:02 -07:00 committed by Alena Prokharchyk
parent 59c4a298e8
commit d70f95a3d6

View File

@ -13,6 +13,7 @@ type Embed struct {
Ignore []string Ignore []string
ignoreOverride bool ignoreOverride bool
embeddedFields []string embeddedFields []string
EmptyValueOk bool
} }
func (e *Embed) FromInternal(data map[string]interface{}) { func (e *Embed) FromInternal(data map[string]interface{}) {
@ -39,6 +40,9 @@ func (e *Embed) ToInternal(data map[string]interface{}) {
delete(data, fieldName) delete(data, fieldName)
} }
if len(sub) == 0 { if len(sub) == 0 {
if e.EmptyValueOk {
data[e.Field] = nil
}
return return
} }
data[e.Field] = sub data[e.Field] = sub