Skip to content

Commit

Permalink
fixed: use IdentifiableList when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Jan 23, 2019
1 parent 9344cb6 commit 9fe637f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cmd/elegen/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ func attrToField(set spec.SpecificationSet, shadow bool, attr *spec.Attribute) s
case spec.AttributeTypeRef:
convertedType = pointerShadow + pointer + set.Specification(attr.SubType).Model().EntityName
case spec.AttributeTypeRefList:
convertedType = pointerShadow + "[]" + pointer + set.Specification(attr.SubType).Model().EntityName
remoteSpec := set.Specification(attr.SubType)
if remoteSpec.Model().Detached {
convertedType = pointerShadow + "[]" + pointer + remoteSpec.Model().EntityName
} else {
convertedType = pointerShadow + pointer + remoteSpec.Model().EntityNamePlural + "List"
}
case spec.AttributeTypeRefMap:
convertedType = pointerShadow + "map[string]" + pointer + set.Specification(attr.SubType).Model().EntityName
default:
Expand Down Expand Up @@ -295,14 +300,22 @@ func writeDefaultValue(set spec.SpecificationSet, s spec.Specification, attr *sp
}

switch attr.Type {

case spec.AttributeTypeList:
if attr.DefaultValue == nil {
return ref + attr.ConvertedType + "{}"
}

case spec.AttributeTypeRef:
return ref + set.Specification(attr.SubType).Model().EntityName + "()"

case spec.AttributeTypeRefList:
return "[]" + pointer + set.Specification(attr.SubType).Model().EntityName + "{}"
remoteSpec := set.Specification(attr.SubType)
if remoteSpec.Model().Detached {
return "[]" + pointer + remoteSpec.Model().EntityName + "{}"
}
return pointer + remoteSpec.Model().EntityNamePlural + "List{}"

case spec.AttributeTypeRefMap:
return "map[string]" + pointer + set.Specification(attr.SubType).Model().EntityName + "{}"
}
Expand Down

0 comments on commit 9fe637f

Please sign in to comment.