Skip to content

Commit

Permalink
commentFormatting: put a space between // and comment text
Browse files Browse the repository at this point in the history
  • Loading branch information
Royal-go committed Nov 26, 2024
1 parent 200ddb1 commit 2c34879
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions database/gdb/gdb_model_create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ var autoIncrementMapping = map[string]string{
"oracle": "GENERATED BY DEFAULT AS IDENTITY",
"dm": "AUTO_INCREMENT",
"duckdb": "", // 内存库,不支持传统意义上的自增
"pgsql": "SERIAL", //最新版本psql 使用BIGSERIAL
"pgsql": "SERIAL", // 最新版本pgsql 使用BIGSERIAL
"clickhouse": "AUTO_INCREMENT",
}

Expand All @@ -216,13 +216,13 @@ func (m *Model) AutoMigrate(ctx context.Context, model interface{}) error {
// 获取数据库类型
dbType := m.db.GetCore().config.Type

//获取字段类型映射
// 获取字段类型映射
typeMap, ok := typeMapping[dbType]
if !ok {
return fmt.Errorf("unsupported database type: %s", dbType)
}

//获取自增字段语法映射
// 获取自增字段语法映射
autoIncrement, ok := autoIncrementMapping[dbType]
if !ok {
return fmt.Errorf("unsupported database type for auto increment: %s", dbType)
Expand All @@ -233,13 +233,13 @@ func (m *Model) AutoMigrate(ctx context.Context, model interface{}) error {
field := t.Field(i)
// 将字段名称转换为小写并用下划线分隔
fieldName := gstr.CaseSnake(field.Name)
//如果存在 orm 中的配置 则取orm中配置的字段名
// 如果存在 orm 中的配置 则取orm中配置的字段名
ormTag := field.Tag.Get("orm")
if ormTag != "" {
fieldName = ormTag
}

//使用默认的字段类型映射
// 使用默认的字段类型映射
fieldType, ok := typeMap[field.Type.Kind()]
if !ok {
return fmt.Errorf("unsupported field type: %s", field.Type.Kind())
Expand All @@ -258,7 +258,7 @@ func (m *Model) AutoMigrate(ctx context.Context, model interface{}) error {
columns = append(columns, columnDef)
}

//默认给 id 字段设置为主键,orm标签目前是配置的字段,后续考虑通过配置orm标签扩展主键自增
// 默认给 id 字段设置为主键,orm标签目前是配置的字段,后续考虑通过配置orm标签扩展主键自增
for i, column := range columns {
if gstr.Contains(column, "id") {
columns[i] = column + " PRIMARY KEY UNIQUE " + autoIncrement
Expand Down

0 comments on commit 2c34879

Please sign in to comment.