diff --git a/field_options.go b/field_options.go index 107afaac..f7acd5a6 100644 --- a/field_options.go +++ b/field_options.go @@ -51,30 +51,34 @@ var ( nullable := false if strings.HasPrefix(ft, "*") { nullable = true - ft = ft[1:] + ft = strings.TrimLeft(ft, "*") } if !all && !nullable { return f } switch ft { + case "time.Time": + ft = "sql.NullTime" case "string": - f.Type = "sql.NullString" + ft = "sql.NullString" case "int", "int64", "uint", "uint32", "uint64": - f.Type = "sql.NullInt64" + ft = "sql.NullInt64" case "uint16", "int32": - f.Type = "sql.NullInt32" + ft = "sql.NullInt32" case "int8", "uint8", "int16": - f.Type = "sql.NullInt16" + ft = "sql.NullInt16" case "byte": - f.Type = "sql.NullByte" + ft = "sql.NullByte" case "float64", "float32": - f.Type = "sql.NullFloat64" + ft = "sql.NullFloat64" case "bool": - f.Type = "sql.NullBool" - case "time.Time": - f.Type = "sql.NullTime" + ft = "sql.NullBool" + default: + return f } + f.CustomGenType = f.GenType() + f.Type = ft return f } }