-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.go
186 lines (178 loc) · 5.04 KB
/
register.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package sql
import (
"database/sql"
"github.com/powerpuffpenguin/goja"
)
func (f *factory) register() {
f.Set(`Open`, sql.Open)
f.Set(`OpenDB`, sql.OpenDB)
f.Accessor(`LevelDefault`, f.getLevelDefault, nil)
f.Accessor(`LevelReadUncommitted`, f.getLevelReadUncommitted, nil)
f.Accessor(`LevelReadCommitted`, f.getLevelReadCommitted, nil)
f.Accessor(`LevelWriteCommitted`, f.getLevelWriteCommitted, nil)
f.Accessor(`LevelRepeatableRead`, f.getLevelRepeatableRead, nil)
f.Accessor(`LevelSnapshot`, f.getLevelSnapshot, nil)
f.Accessor(`LevelSerializable`, f.getLevelSerializable, nil)
f.Accessor(`LevelLinearizable`, f.getLevelLinearizable, nil)
f.Set(`Named`, sql.Named)
f.Set(`NullBool`, NullBool)
f.Set(`NullFloat64`, NullFloat64)
f.Set(`NullInt32`, NullInt32)
f.Set(`NullInt64`, NullInt64)
f.Set(`NullString`, NullString)
f.Set(`NullTime`, NullTime)
f.Set(`TxOptions`, TxOptions)
f.Set(`isColumnTypePointer`, isColumnTypePointer)
f.Set(`isConnPointer`, isConnPointer)
f.Set(`isDBPointer`, isDBPointer)
f.Set(`isDBStats`, isDBStats)
f.Set(`isIsolationLevel`, isIsolationLevel)
f.Set(`isNamedArg`, isNamedArg)
f.Set(`isNullBoolPointer`, isNullBoolPointer)
f.Set(`isNullFloat64Pointer`, isNullFloat64Pointer)
f.Set(`isNullInt32Pointer`, isNullInt32Pointer)
f.Set(`isNullInt64Pointer`, isNullInt64Pointer)
f.Set(`isNullStringPointer`, isNullStringPointer)
f.Set(`isNullTimePointer`, isNullTimePointer)
f.Set(`isOut`, isOut)
f.Set(`isRawBytes`, isRawBytes)
f.Set(`isResult`, isResult)
f.Set(`isRowPointer`, isRowPointer)
f.Set(`isRowsPointer`, isRowsPointer)
f.Set(`isScanner`, isScanner)
f.Set(`isStmtPointer`, isStmtPointer)
f.Set(`isTxPointer`, isTxPointer)
f.Set(`isTxOptionsPointer`, isTxOptionsPointer)
}
func TxOptions(isolation sql.IsolationLevel, readOnly bool) *sql.TxOptions {
return &sql.TxOptions{
Isolation: isolation,
ReadOnly: readOnly,
}
}
func NullBool() *sql.NullBool {
return &sql.NullBool{}
}
func NullFloat64() *sql.NullFloat64 {
return &sql.NullFloat64{}
}
func NullInt32() *sql.NullInt32 {
return &sql.NullInt32{}
}
func NullInt64() *sql.NullInt64 {
return &sql.NullInt64{}
}
func NullString() *sql.NullString {
return &sql.NullString{}
}
func NullTime() *sql.NullTime {
return &sql.NullTime{}
}
func (f *factory) getLevelDefault(call goja.FunctionCall) goja.Value {
return f.runtime.ToValue(sql.LevelDefault)
}
func (f *factory) getLevelReadUncommitted(call goja.FunctionCall) goja.Value {
return f.runtime.ToValue(sql.LevelReadUncommitted)
}
func (f *factory) getLevelReadCommitted(call goja.FunctionCall) goja.Value {
return f.runtime.ToValue(sql.LevelReadCommitted)
}
func (f *factory) getLevelWriteCommitted(call goja.FunctionCall) goja.Value {
return f.runtime.ToValue(sql.LevelWriteCommitted)
}
func (f *factory) getLevelRepeatableRead(call goja.FunctionCall) goja.Value {
return f.runtime.ToValue(sql.LevelRepeatableRead)
}
func (f *factory) getLevelSnapshot(call goja.FunctionCall) goja.Value {
return f.runtime.ToValue(sql.LevelSnapshot)
}
func (f *factory) getLevelSerializable(call goja.FunctionCall) goja.Value {
return f.runtime.ToValue(sql.LevelSerializable)
}
func (f *factory) getLevelLinearizable(call goja.FunctionCall) goja.Value {
return f.runtime.ToValue(sql.LevelLinearizable)
}
func isColumnTypePointer(i interface{}) bool {
_, result := i.(*sql.ColumnType)
return result
}
func isConnPointer(i interface{}) bool {
_, result := i.(*sql.Conn)
return result
}
func isDBPointer(i interface{}) bool {
_, result := i.(*sql.DB)
return result
}
func isDBStats(i interface{}) bool {
_, result := i.(sql.DBStats)
return result
}
func isIsolationLevel(i interface{}) bool {
_, result := i.(sql.IsolationLevel)
return result
}
func isNamedArg(i interface{}) bool {
_, result := i.(sql.NamedArg)
return result
}
func isNullBoolPointer(i interface{}) bool {
_, result := i.(*sql.NullBool)
return result
}
func isNullFloat64Pointer(i interface{}) bool {
_, result := i.(*sql.NullFloat64)
return result
}
func isNullInt32Pointer(i interface{}) bool {
_, result := i.(*sql.NullInt32)
return result
}
func isNullInt64Pointer(i interface{}) bool {
_, result := i.(*sql.NullInt64)
return result
}
func isNullStringPointer(i interface{}) bool {
_, result := i.(*sql.NullString)
return result
}
func isNullTimePointer(i interface{}) bool {
_, result := i.(*sql.NullTime)
return result
}
func isOut(i interface{}) bool {
_, result := i.(sql.Out)
return result
}
func isRawBytes(i interface{}) bool {
_, result := i.(sql.RawBytes)
return result
}
func isResult(i interface{}) bool {
_, result := i.(sql.Result)
return result
}
func isRowPointer(i interface{}) bool {
_, result := i.(*sql.Row)
return result
}
func isRowsPointer(i interface{}) bool {
_, result := i.(*sql.Rows)
return result
}
func isScanner(i interface{}) bool {
_, result := i.(sql.Scanner)
return result
}
func isStmtPointer(i interface{}) bool {
_, result := i.(*sql.Stmt)
return result
}
func isTxPointer(i interface{}) bool {
_, result := i.(*sql.Tx)
return result
}
func isTxOptionsPointer(i interface{}) bool {
_, result := i.(*sql.TxOptions)
return result
}