autoMigrate支持动态生成表

This commit is contained in:
Caisin 2022-08-15 17:35:35 +08:00
parent 8c3018b96a
commit a76c7f88a1

View File

@ -123,8 +123,12 @@ func ParseWithSpecialTableName(dest interface{}, cacheStore *sync.Map, namer Nam
modelValue := reflect.New(modelType)
tableName := namer.TableName(modelType.Name())
if tabler, ok := modelValue.Interface().(Tabler); ok {
if value.Kind() == reflect.Ptr {
tableName = dest.(Tabler).TableName()
} else {
tableName = tabler.TableName()
}
}
if en, ok := namer.(embeddedNamer); ok {
tableName = en.Table
}