Skip to content

Commit

Permalink
Only set type if id is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Jul 31, 2018
1 parent 0933187 commit 5a8ca5f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions types/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand All @@ -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 {
Expand Down

0 comments on commit 5a8ca5f

Please sign in to comment.