@@ -45,9 +45,9 @@ func ExampleNew() {
45
45
46
46
fmt .Println ("query:" )
47
47
fmt .Println (query )
48
- fmt .Println ("args :" )
48
+ fmt .Println ("\n args :" )
49
49
fmt .Println (args )
50
- fmt .Println ("debug :" )
50
+ fmt .Println ("\n debug :" )
51
51
fmt .Println (debug )
52
52
53
53
// Output:
@@ -56,8 +56,10 @@ func ExampleNew() {
56
56
// SELECT foo, bar FROM users
57
57
// WHERE active IS TRUE
58
58
// AND user_id = $1 OR user = $2
59
+ //
59
60
// args:
60
61
// [42 root]
62
+ //
61
63
// debug:
62
64
// SELECT foo, bar FROM 'users'
63
65
// WHERE active IS TRUE
@@ -130,7 +132,8 @@ func ExampleBuilder_DebugBuild() {
130
132
b .Addf ("MORE offset = %$" , d )
131
133
b .Addf ("MAYBE IN arr = %$" , []int {1 , 2 , 3 })
132
134
133
- fmt .Printf ("debug:\n %v" , b .DebugBuild ())
135
+ fmt .Println ("debug:" )
136
+ fmt .Println (b .DebugBuild ())
134
137
135
138
// Output:
136
139
// debug:
@@ -283,27 +286,27 @@ func Example_queryWhere() {
283
286
"limit" : 100.1 ,
284
287
}
285
288
286
- var b builq.Builder
287
- b . Addf ("SELECT * FROM foo" )
288
- b . Addf ("WHERE active IS TRUE" )
289
+ q := builq .New ()
290
+ q ("SELECT * FROM foo" )
291
+ q ("WHERE active IS TRUE" )
289
292
290
293
if name , ok := filter ["name" ]; ok {
291
- b . Addf ("AND name = %$" , name )
294
+ q ("AND name = %$" , name )
292
295
}
293
296
if cat , ok := filter ["category" ]; ok {
294
- b . Addf ("AND category IN (%+$)" , cat )
297
+ q ("AND category IN (%+$)" , cat )
295
298
}
296
299
if pat , ok := filter ["pat" ]; ok {
297
- b . Addf ("AND page LIKE '%s'" , pat )
300
+ q ("AND page LIKE '%s'" , pat )
298
301
}
299
302
if prob , ok := filter ["prob" ]; ok {
300
- b . Addf ("AND prob < %s" , prob )
303
+ q ("AND prob < %s" , prob )
301
304
}
302
305
if limit , ok := filter ["limit" ]; ok {
303
- b . Addf ("LIMIT %d;" , limit )
306
+ q ("LIMIT %d;" , limit )
304
307
}
305
308
306
- query , args , err := b .Build ()
309
+ query , args , err := q .Build ()
307
310
if err != nil {
308
311
panic (err )
309
312
}
0 commit comments