-
-
Notifications
You must be signed in to change notification settings - Fork 361
/
def.go
90 lines (87 loc) · 3.01 KB
/
def.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package cnf
// EImportsHead imports head options. import包含选项
var EImportsHead = map[string]string{
"stirng": `"string"`,
"time.Time": `"time"`,
"gorm.Model": `"gorm.io/gorm"`,
"fmt": `"fmt"`,
"datatypes.JSON": `"gorm.io/datatypes"`,
"datatypes.Date": `"gorm.io/datatypes"`,
}
// TypeMysqlDicMp Accurate matching type.精确匹配类型
var TypeMysqlDicMp = map[string]string{
"smallint": "int16",
"smallint unsigned": "uint16",
"int": "int",
"int unsigned": "uint",
"bigint": "int64",
"bigint unsigned": "uint64",
"mediumint": "int32",
"mediumint unsigned": "uint32",
"varchar": "string",
"char": "string",
"date": "datatypes.Date",
"datetime": "time.Time",
"bit(1)": "[]uint8",
"tinyint": "int8",
"tinyint unsigned": "uint8",
"tinyint(1)": "bool", // tinyint(1) 默认设置成bool
"tinyint(1) unsigned": "bool", // tinyint(1) 默认设置成bool
"json": "datatypes.JSON",
"text": "string",
"timestamp": "time.Time",
"double": "float64",
"double unsigned": "float64",
"mediumtext": "string",
"longtext": "string",
"float": "float32",
"float unsigned": "float32",
"tinytext": "string",
"enum": "string",
"time": "time.Time",
"tinyblob": "[]byte",
"blob": "[]byte",
"mediumblob": "[]byte",
"longblob": "[]byte",
"integer": "int64",
"numeric": "float64",
"smalldatetime": "time.Time", //sqlserver
"nvarchar": "string",
"real": "float32",
"binary": "[]byte",
"geometry": "[]byte",
}
// 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+[)]`, "int16"},
{`^(mediumint)[(]\d+[)] unsigned`, "uint16"},
{`^(double)[(]\d+,\d+[)]`, "float64"},
{`^(float)[(]\d+,\d+[)]`, "float64"},
{`^(datetime)[(]\d+[)]`, "time.Time"},
{`^(bit)[(]\d+[)]`, "[]uint8"},
{`^(text)[(]\d+[)]`, "string"},
{`^(integer)[(]\d+[)]`, "int"},
{`^(timestamp)[(]\d+[)]`, "time.Time"},
{`^(geometry)[(]\d+[)]`, "[]byte"},
{`^(set)[(][\s\S]+[)]`, "string"},
}