Skip to content

Commit

Permalink
generate slice types on the model
Browse files Browse the repository at this point in the history
  • Loading branch information
samnguyen-outreach committed Sep 29, 2022
1 parent 38b6caf commit a45442b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion generator/template/model_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func getUserDefinedType(column metadata.Column) string {
switch column.DataType.Kind {
case metadata.EnumType:
return utils.ToGoIdentifier(column.DataType.Name)
case metadata.UserDefinedType, metadata.ArrayType:
case metadata.UserDefinedType:
return "string"
}

Expand All @@ -258,6 +258,11 @@ func getUserDefinedType(column metadata.Column) string {
func getGoType(column metadata.Column) interface{} {
defaultGoType := toGoType(column)

if column.DataType.Kind == metadata.ArrayType {
sliceType := reflect.SliceOf(reflect.TypeOf(defaultGoType))
return reflect.Zero(sliceType).Interface()
}

if column.IsNullable {
return reflect.New(reflect.TypeOf(defaultGoType)).Interface()
}
Expand Down
1 change: 1 addition & 0 deletions out/array_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package out

0 comments on commit a45442b

Please sign in to comment.