diff --git a/generator/template/model_template.go b/generator/template/model_template.go index 032afc87..8f19bc40 100644 --- a/generator/template/model_template.go +++ b/generator/template/model_template.go @@ -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" } @@ -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() } diff --git a/out/array_test.go b/out/array_test.go new file mode 100644 index 00000000..c7bd478e --- /dev/null +++ b/out/array_test.go @@ -0,0 +1 @@ +package out