1
0
mirror of https://github.com/rancher/norman.git synced 2025-07-30 22:35:29 +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
ignoreOverride bool
embeddedFields []string
EmptyValueOk bool
}
func (e *Embed) FromInternal(data map[string]interface{}) {
@ -39,6 +40,9 @@ func (e *Embed) ToInternal(data map[string]interface{}) {
delete(data, fieldName)
}
if len(sub) == 0 {
if e.EmptyValueOk {
data[e.Field] = nil
}
return
}
data[e.Field] = sub