diff --git a/README.md b/README.md index 0dfebce..d6cb8fe 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Available commands: ````yaml # ./config/database.yaml connections: - mysql: + connect_name: driver: mysql host: env("DB_HOST", "127.0.0.1") port: env("DB_PORT", "3306") @@ -46,6 +46,7 @@ connections: username: env("DB_USERNAME", "root") password: env("DB_PASSWORD", "123456") ```` +其中`connect_name`为自定义的连接名,`driver`现支持`mysql`、`postgresql`、`redis` ````shell user@macOs path $ toolset make:orm -config=./config/database.yaml -out=your_path ```` diff --git a/console/commands/pgorm/pgsql.go b/console/commands/pgorm/pgsql.go index 5875959..efcb3b1 100644 --- a/console/commands/pgorm/pgsql.go +++ b/console/commands/pgorm/pgsql.go @@ -409,6 +409,7 @@ WHERE pg_class.relname = $1 AND pg_constraint.contype = 'p' for __rows.Next() { _ = __rows.Scan(&pkey) } + repeatName := map[string]int{} for _rows.Next() { var ( column_name string @@ -422,6 +423,11 @@ WHERE pg_class.relname = $1 AND pg_constraint.contype = 'p' if err != nil { panic(err) } + if _, ok := repeatName[column_name]; ok { + continue + } else { + repeatName[column_name] = 1 + } var columnComment, indexName string if comment != nil { columnComment = *comment @@ -505,7 +511,7 @@ func PgTypeToGoType(pgType string, columnName string) string { case "int8": return "int64" case "date": - return "datatypes.Date" + return "database.Time" case "json", "jsonb": return "database.JSON" case "time", "timetz":