-
-
Notifications
You must be signed in to change notification settings - Fork 179
/
util.go
50 lines (42 loc) · 952 Bytes
/
util.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
package psql
import (
"bytes"
"strconv"
)
func alias(w *bytes.Buffer, alias string) {
w.WriteString(` AS `)
w.WriteString(alias)
}
func aliasWithID(w *bytes.Buffer, alias string, id int32) {
w.WriteString(` AS `)
w.WriteString(alias)
w.WriteString(`_`)
int32String(w, id)
}
func colWithTable(w *bytes.Buffer, table, col string) {
w.WriteString(table)
w.WriteString(`.`)
w.WriteString(col)
}
func colWithTableID(w *bytes.Buffer, table string, id int32, col string) {
w.WriteString(table)
if id >= 0 {
w.WriteString(`_`)
int32String(w, id)
}
w.WriteString(`.`)
w.WriteString(col)
}
func quoted(w *bytes.Buffer, identifier string) {
// w.WriteString(`"`)
w.WriteString(identifier)
// w.WriteString(`"`)
}
func squoted(w *bytes.Buffer, identifier string) {
w.WriteString(`'`)
w.WriteString(identifier)
w.WriteString(`'`)
}
func int32String(w *bytes.Buffer, val int32) {
w.WriteString(strconv.FormatInt(int64(val), 10))
}