-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexample_sqlutil_test.go
More file actions
74 lines (54 loc) · 1002 Bytes
/
example_sqlutil_test.go
File metadata and controls
74 lines (54 loc) · 1002 Bytes
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
package sqlutil_test
import (
"fmt"
"log"
"github.com/tecnickcom/gogen/pkg/sqlutil"
)
func ExampleSQLUtil_QuoteID() {
q, err := sqlutil.New()
if err != nil {
log.Fatal(err)
}
o := q.QuoteID("7919")
fmt.Println(o)
// Output:
// `7919`
}
func ExampleWithQuoteIDFunc() {
// define custom quote function
fn := func(s string) string { return "TEST-" + s }
q, err := sqlutil.New(
sqlutil.WithQuoteIDFunc(fn),
)
if err != nil {
log.Fatal(err)
}
o := q.QuoteID("6971")
fmt.Println(o)
// Output:
// TEST-6971
}
func ExampleSQLUtil_QuoteValue() {
q, err := sqlutil.New()
if err != nil {
log.Fatal(err)
}
o := q.QuoteValue("5867")
fmt.Println(o)
// Output:
// '5867'
}
func ExampleWithQuoteValueFunc() {
// define custom quote function
fn := func(s string) string { return "TEST-" + s }
q, err := sqlutil.New(
sqlutil.WithQuoteValueFunc(fn),
)
if err != nil {
log.Fatal(err)
}
o := q.QuoteValue("4987")
fmt.Println(o)
// Output:
// TEST-4987
}