Skip to content

Commit

Permalink
fix HashMap is out of order
Browse files Browse the repository at this point in the history
fix HashMap is out of order
  • Loading branch information
xxjwxc committed Dec 28, 2020
1 parent acd9861 commit a60ccdc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
55 changes: 29 additions & 26 deletions data/view/cnf/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,33 @@ var TypeMysqlDicMp = map[string]string{
"integer": "int64",
}

// TypeMysqlMatchMp Fuzzy Matching Types.模糊匹配类型
var TypeMysqlMatchMp = map[string]string{
`^(tinyint)[(]\d+[)] unsigned`: "uint8",
`^(smallint)[(]\d+[)] unsigned`: "uint16",
`^(int)[(]\d+[)] unsigned`: "uint32",
`^(bigint)[(]\d+[)] unsigned`: "uint64",
`^(tinyint)[(]\d+[)]`: "int8",
`^(smallint)[(]\d+[)]`: "int16",
`^(int)[(]\d+[)]`: "int",
`^(bigint)[(]\d+[)]`: "int64",
`^(char)[(]\d+[)]`: "string",
`^(enum)[(](.)+[)]`: "string",
`^(varchar)[(]\d+[)]`: "string",
`^(varbinary)[(]\d+[)]`: "[]byte",
`^(blob)[(]\d+[)]`: "[]byte",
`^(binary)[(]\d+[)]`: "[]byte",
`^(decimal)[(]\d+,\d+[)]`: "float64",
`^(mediumint)[(]\d+[)]`: "string",
`^(double)[(]\d+,\d+[)]`: "float64",
`^(double)[(]\d+,\d+[)] unsigned`: "float64",
`^(float)[(]\d+,\d+[)]`: "float64",
`^(float)[(]\d+,\d+[)] unsigned`: "float64",
`^(datetime)[(]\d+[)]`: "time.Time",
`^(bit)[(]\d+[)]`: "[]uint8",
`^(text)[(]\d+[)]`: "string",
`^(integer)[(]\d+[)]`: "int",
// TypeMysqlMatchList Fuzzy Matching Types.模糊匹配类型
var TypeMysqlMatchList = []struct {
Key string
Value string
}{
{`^(tinyint)[(]\d+[)] unsigned`, "uint8"},
{`^(smallint)[(]\d+[)] unsigned`, "uint16"},
{`^(int)[(]\d+[)] unsigned`, "uint32"},
{`^(bigint)[(]\d+[)] unsigned`, "uint64"},
{`^(float)[(]\d+,\d+[)] unsigned`, "float64"},
{`^(double)[(]\d+,\d+[)] unsigned`, "float64"},
{`^(tinyint)[(]\d+[)]`, "int8"},
{`^(smallint)[(]\d+[)]`, "int16"},
{`^(int)[(]\d+[)]`, "int"},
{`^(bigint)[(]\d+[)]`, "int64"},
{`^(char)[(]\d+[)]`, "string"},
{`^(enum)[(](.)+[)]`, "string"},
{`^(varchar)[(]\d+[)]`, "string"},
{`^(varbinary)[(]\d+[)]`, "[]byte"},
{`^(blob)[(]\d+[)]`, "[]byte"},
{`^(binary)[(]\d+[)]`, "[]byte"},
{`^(decimal)[(]\d+,\d+[)]`, "float64"},
{`^(mediumint)[(]\d+[)]`, "string"},
{`^(double)[(]\d+,\d+[)]`, "float64"},
{`^(float)[(]\d+,\d+[)]`, "float64"},
{`^(datetime)[(]\d+[)]`, "time.Time"},
{`^(bit)[(]\d+[)]`, "[]uint8"},
{`^(text)[(]\d+[)]`, "string"},
{`^(integer)[(]\d+[)]`, "int"},
}
6 changes: 3 additions & 3 deletions data/view/model/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func getTypeName(name string, isNull bool) string {
}

// Fuzzy Regular Matching.模糊正则匹配
for k, v := range cnf.TypeMysqlMatchMp {
if ok, _ := regexp.MatchString(k, name); ok {
return fixNullToPorint(v, isNull)
for _, l := range cnf.TypeMysqlMatchList {
if ok, _ := regexp.MatchString(l.Key, name); ok {
return fixNullToPorint(l.Value, isNull)
}
}

Expand Down

0 comments on commit a60ccdc

Please sign in to comment.