add 'DEFAULT NULL' to point

添加默认值为null 转换成指针类型
This commit is contained in:
谢小军
2020-06-23 12:10:08 +08:00
parent 19b39a0b41
commit 0706dd0747
9 changed files with 39 additions and 27 deletions

View File

@@ -55,22 +55,39 @@ func FilterKeywords(src string) string {
}
// getTypeName Type acquisition filtering.类型获取过滤
func getTypeName(name string) string {
func getTypeName(name string, isNull bool) string {
// Precise matching first.先精确匹配
if v, ok := cnf.TypeMysqlDicMp[name]; ok {
return v
return fixNullToPorint(v, isNull)
}
// Fuzzy Regular Matching.模糊正则匹配
for k, v := range cnf.TypeMysqlMatchMp {
if ok, _ := regexp.MatchString(k, name); ok {
return v
return fixNullToPorint(v, isNull)
}
}
panic(fmt.Sprintf("type (%v) not match in any way.maybe need to add on (https://github.com/xxjwxc/gormt/blob/master/data/view/cnf/def.go)", name))
}
// 过滤null point 类型
func fixNullToPorint(name string, isNull bool) string {
if isNull && config.GetIsNullToPoint() {
if strings.HasPrefix(name, "uint") {
return "*" + name
}
if strings.HasPrefix(name, "int") {
return "*" + name
}
if strings.HasPrefix(name, "float") {
return "*" + name
}
}
return name
}
func getUninStr(left, middle, right string) string {
re := left
if len(right) > 0 {