Skip to content

Commit

Permalink
feat: set gen type
Browse files Browse the repository at this point in the history
  • Loading branch information
qqxhb committed Oct 17, 2024
1 parent d3a17ac commit 5986eb6
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions field_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 5986eb6

Please sign in to comment.