diff --git a/types/mapper.go b/types/mapper.go index 397c1f313..04f1ae0b2 100644 --- a/types/mapper.go +++ b/types/mapper.go @@ -82,18 +82,12 @@ func (t *typeMapper) FromInternal(data map[string]interface{}) { } } - // Attempt to set type so mappers are aware of it if _, ok := data["type"]; !ok && data != nil { data["type"] = t.typeName } Mappers(t.Mappers).FromInternal(data) - // Ensure if there is no type we set one - if _, ok := data["type"]; !ok && data != nil { - data["type"] = t.typeName - } - if data != nil && t.root { if _, ok := data["id"]; ok { if namespace != "" { @@ -110,6 +104,12 @@ func (t *typeMapper) FromInternal(data map[string]interface{}) { } } } + + if _, ok := data["type"]; !ok && data != nil { + if _, ok := data["id"]; ok { + data["type"] = t.typeName + } + } } func (t *typeMapper) ToInternal(data map[string]interface{}) error {