mirror of
https://github.com/zhufuyi/sponge.git
synced 2025-12-24 10:40:55 +08:00
change proto field type
This commit is contained in:
@@ -956,8 +956,8 @@ func goTypeToProto(fields []tmplField) []tmplField {
|
||||
field.GoType = "int32"
|
||||
case "uint":
|
||||
field.GoType = "uint32"
|
||||
case "time.Time":
|
||||
field.GoType = "int64"
|
||||
case "time.Time", "*time.Time":
|
||||
field.GoType = "string"
|
||||
case "float32":
|
||||
field.GoType = "float"
|
||||
case "float64":
|
||||
@@ -978,6 +978,13 @@ func goTypeToProto(fields []tmplField) []tmplField {
|
||||
} else if strings.Contains(field.GoType, "[]*") {
|
||||
field.GoType = "repeated " + strings.ReplaceAll(field.GoType, "[]*", "")
|
||||
}
|
||||
if field.GoType == "[]time.Time" {
|
||||
field.GoType = "repeated string"
|
||||
}
|
||||
} else {
|
||||
if strings.ToLower(field.Name) == "id" {
|
||||
field.GoType = "uint64"
|
||||
}
|
||||
}
|
||||
|
||||
newFields = append(newFields, field)
|
||||
|
||||
@@ -29,21 +29,9 @@ func GetSqliteTableInfo(dbFile string, tableName string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
//sql = handleID(sql)
|
||||
for k, v := range sqliteToMysqlTypeMap {
|
||||
sql = strings.ReplaceAll(sql, k, v)
|
||||
}
|
||||
|
||||
return sql, nil
|
||||
}
|
||||
|
||||
//func handleID(sql string) string {
|
||||
// re := regexp.MustCompile(`id\s+INTEGER`)
|
||||
// matches := re.FindAllStringSubmatch(sql, -1)
|
||||
//
|
||||
// for _, match := range matches {
|
||||
// sql = strings.ReplaceAll(sql, match[0], " id bigint unsigned")
|
||||
// }
|
||||
//
|
||||
// return sql
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user