Skip to content

Commit

Permalink
update: pgsql恢复default,过滤包含::的default
Browse files Browse the repository at this point in the history
  • Loading branch information
zodial committed Nov 21, 2024
1 parent 2746bc4 commit 9419126
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion console/commands/pgorm/pgsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ func getImports(infos map[string]orm.TableInfos, tableColumns map[string][]table

func genOrmStruct(table string, columns []tableColumn, conf Conf, relationships []*orm.Relationship) string {
TableName := parser.StringToHump(table)
if TableName == "Tests" {
fmt.Println("a")
}
config := services.NewConfig(conf)
deletedField := config.GetString("deleted_field")
hasField := make(map[string]bool)
Expand Down Expand Up @@ -347,7 +350,10 @@ func genGormTag(column tableColumn, conf Conf) string {
} else if column.IndexName != "" {
arr = append(arr, "index:"+column.ColumnName)
}
// pgsql取消default声明, pgsql的default大多为函数,会影响数据更新,由pgsql自身处理
// default
if column.ColumnDefault != "" && !strings.Contains(column.ColumnDefault, "::") {
arr = append(arr, "default:"+column.ColumnDefault)
}
// created_at & updated_at
if field, ok := conf["created_field"]; ok && field == column.ColumnName {
arr = append(arr, "autoCreateTime")
Expand Down

0 comments on commit 9419126

Please sign in to comment.