mirror of
https://github.com/rancher/norman.git
synced 2025-07-31 14:54:38 +00:00
Changes to Mapper embed to insert nil value if applicable for a schema field
This commit is contained in:
parent
59c4a298e8
commit
d70f95a3d6
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user