-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.go
92 lines (88 loc) · 2.35 KB
/
init.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
91
92
// Package orm
package orm
import "github.com/assembly-hub/orm/dbtype"
type dbCoreData struct {
DBType int
StrEsc string
EscStart string
EscEnd string
Esc string
BinStr string
IgnoreStr string
}
var dbConfMap map[int]*dbCoreData
func init() {
dbConfMap = make(map[int]*dbCoreData)
dbConfMap[dbtype.MySQL] = &dbCoreData{
DBType: dbtype.MySQL,
StrEsc: "'",
EscStart: "`",
EscEnd: "`",
Esc: "\\",
BinStr: "binary", // 数据库不区分大小写;放在数据之前,强制区分大小写
}
dbConfMap[dbtype.MariaDB] = &dbCoreData{
DBType: dbtype.MariaDB,
StrEsc: "'",
EscStart: "`",
EscEnd: "`",
Esc: "\\",
BinStr: "binary", // 数据库不区分大小写;放在数据之前,强制区分大小写
}
dbConfMap[dbtype.SQLServer] = &dbCoreData{
DBType: dbtype.SQLServer,
StrEsc: "'",
EscStart: "[",
EscEnd: "]",
Esc: "%",
BinStr: "COLLATE Chinese_PRC_CS_AS", // 数据库不区分大小写;放在操作符之前,强制区分大小写
}
dbConfMap[dbtype.Postgres] = &dbCoreData{
DBType: dbtype.Postgres,
StrEsc: "'",
EscStart: "\"",
EscEnd: "\"",
Esc: "\\",
IgnoreStr: "", // 数据库本身区分大小写
}
dbConfMap[dbtype.OpenGauss] = &dbCoreData{
DBType: dbtype.OpenGauss,
StrEsc: "'",
EscStart: "\"",
EscEnd: "\"",
Esc: "\\",
IgnoreStr: "", // 数据库本身区分大小写
}
dbConfMap[dbtype.SQLite2] = &dbCoreData{
DBType: dbtype.SQLite2,
StrEsc: "'",
EscStart: "\"",
EscEnd: "\"",
Esc: "",
IgnoreStr: "COLLATE NOCASE", // 数据库本身区分大小写;放在操作符之前,忽略大小写
}
dbConfMap[dbtype.SQLite3] = &dbCoreData{
DBType: dbtype.SQLite3,
StrEsc: "'",
EscStart: "\"",
EscEnd: "\"",
Esc: "",
IgnoreStr: "COLLATE NOCASE", // 数据库本身区分大小写,放在操作符之前,忽略大小写
}
dbConfMap[dbtype.Oracle] = &dbCoreData{
DBType: dbtype.Oracle,
StrEsc: "'",
EscStart: "\"",
EscEnd: "\"",
Esc: "",
IgnoreStr: "", // 数据库本身区分大小写
}
dbConfMap[dbtype.ClickHouse] = &dbCoreData{
DBType: dbtype.ClickHouse,
StrEsc: "'",
EscStart: "`",
EscEnd: "`",
Esc: "\\",
BinStr: "binary", // 数据库不区分大小写;放在数据之前,强制区分大小写
}
}