Skip to content

Commit

Permalink
update: pgsql的类型bytea在go改为[]byte
Browse files Browse the repository at this point in the history
  • Loading branch information
zodial committed Sep 23, 2024
1 parent e1f330f commit 34a5f33
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion console/commands/pgorm/pgsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func genOrmStruct(table string, columns []tableColumn, conf Conf, relationships
str := `type {TableName} struct {`
for _, column := range columns {
p := ""
if column.IsNullable && !(column.ColumnName == "deleted_at" && column.GoType == "database.Time") {
if column.IsNullable && !(column.ColumnName == "deleted_at" && column.GoType == "database.Time") && column.PgType != "bytea" {
p = "*"
}
if column.ColumnName == "deleted_at" && column.GoType == "database.Time" {
Expand Down Expand Up @@ -518,6 +518,8 @@ func PgTypeToGoType(pgType string, columnName string) string {
return "database.Time"
case "numeric":
return "float64"
case "bytea":
return "[]byte"
default:
if strings.Contains(pgType, "timestamp") {
if columnName == "deleted_at" {
Expand Down

0 comments on commit 34a5f33

Please sign in to comment.