From 9419126bbd8763d8e0f320ff40231a7797365ed5 Mon Sep 17 00:00:00 2001 From: zodial Date: Thu, 21 Nov 2024 15:56:24 +0800 Subject: [PATCH] =?UTF-8?q?update:=20pgsql=E6=81=A2=E5=A4=8Ddefault?= =?UTF-8?q?=EF=BC=8C=E8=BF=87=E6=BB=A4=E5=8C=85=E5=90=AB::=E7=9A=84default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- console/commands/pgorm/pgsql.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/console/commands/pgorm/pgsql.go b/console/commands/pgorm/pgsql.go index 3c2dd62..d2fbe1c 100644 --- a/console/commands/pgorm/pgsql.go +++ b/console/commands/pgorm/pgsql.go @@ -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) @@ -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")