-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
oracle_keyword_checker.go
142 lines (137 loc) · 3.79 KB
/
oracle_keyword_checker.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package oci8
import "strings"
// 110 key words
var ORACLEKeyword = map[string]string{
"ACCESS": "ACCESS",
"ADD": "ADD",
"ALL": "ALL",
"ALTER": "ALTER",
"AND": "AND",
"ANY": "ANY",
"AS": "AS",
"ASC": "ASC",
"AUDIT": "AUDIT",
"BETWEEN": "BETWEEN",
"BY": "BY",
"CHAR": "CHAR",
"CHECK": "CHECK",
"CLUSTER": "CLUSTER",
"COLUMN": "COLUMN",
"COLUMN_VALUE": "COLUMN_VALUE",
"COMMENT": "COMMENT",
"COMPRESS": "COMPRESS",
"CONNECT": "CONNECT",
"CREATE": "CREATE",
"CURRENT": "CURRENT",
"DATE": "DATE",
"DECIMAL": "DECIMAL",
"DEFAULT": "DEFAULT",
"DELETE": "DELETE",
"DESC": "DESC",
"DISTINCT": "DISTINCT",
"DROP": "DROP",
"ELSE": "ELSE",
"EXCLUSIVE": "EXCLUSIVE",
"EXISTS": "EXISTS",
"FILE": "FILE",
"FLOAT": "FLOAT",
"FOR": "FOR",
"FROM": "FROM",
"GRANT": "GRANT",
"GROUP": "GROUP",
"HAVING": "HAVING",
"IDENTIFIED": "IDENTIFIED",
"IMMEDIATE": "IMMEDIATE",
"IN": "IN",
"INCREMENT": "INCREMENT",
"INDEX": "INDEX",
"INITIAL": "INITIAL",
"INSERT": "INSERT",
"INTEGER": "INTEGER",
"INTERSECT": "INTERSECT",
"INTO": "INTO",
"IS": "IS",
"LEVEL": "LEVEL",
"LIKE": "LIKE",
"LOCK": "LOCK",
"LONG": "LONG",
"MAXEXTENTS": "MAXEXTENTS",
"MINUS": "MINUS",
"MLSLABEL": "MLSLABEL",
"MODE": "MODE",
"MODIFY": "MODIFY",
"NESTED_TABLE_ID": "NESTED_TABLE_ID",
"NOAUDIT": "NOAUDIT",
"NOCOMPRESS": "NOCOMPRESS",
"NOT": "NOT",
"NOWAIT": "NOWAIT",
"NULL": "NULL",
"NUMBER": "NUMBER",
"OF": "OF",
"OFFLINE": "OFFLINE",
"ON": "ON",
"ONLINE": "ONLINE",
"OPTION": "OPTION",
"OR": "OR",
"ORDER": "ORDER",
"PCTFREE": "PCTFREE",
"PRIOR": "PRIOR",
"PUBLIC": "PUBLIC",
"RAW": "RAW",
"RENAME": "RENAME",
"RESOURCE": "RESOURCE",
"REVOKE": "REVOKE",
"ROW": "ROW",
"ROWID": "ROWID",
"ROWNUM": "ROWNUM",
"ROWS": "ROWS",
"SELECT": "SELECT",
"SESSION": "SESSION",
"SET": "SET",
"SHARE": "SHARE",
"SIZE": "SIZE",
"SMALLINT": "SMALLINT",
"START": "START",
"SUCCESSFUL": "SUCCESSFUL",
"SYNONYM": "SYNONYM",
"SYSDATE": "SYSDATE",
"TABLE": "TABLE",
"THEN": "THEN",
"TO": "TO",
"TRIGGER": "TRIGGER",
"UID": "UID",
"UNION": "UNION",
"UNIQUE": "UNIQUE",
"UPDATE": "UPDATE",
"USER": "USER",
"VALIDATE": "VALIDATE",
"VALUES": "VALUES",
"VARCHAR": "VARCHAR",
"VARCHAR2": "VARCHAR2",
"VIEW": "VIEW",
"WHENEVER": "WHENEVER",
"WHERE": "WHERE",
"WITH": "WITH",
}
// Check oralce 保留字
func Check(fieldOrTableName string) bool {
_, ok := ORACLEKeyword[fieldOrTableName]
if ok {
return true
}
if fieldOrTableName != "" {
fieldOrTableName = strings.ToUpper(fieldOrTableName)
}
_, ok = ORACLEKeyword[fieldOrTableName]
return ok
}
func CheckEscape(fieldOrTableName string) bool {
return Check(fieldOrTableName)
}
func CheckAndReplace(fieldOrTableName string) string {
if Check(fieldOrTableName) {
return "\"" + fieldOrTableName + "\""
} else {
return fieldOrTableName
}
}