forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_builder.go
85 lines (73 loc) · 2.33 KB
/
update_builder.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
package db
import (
"database/sql"
"github.com/stellar/go/support/errors"
)
// Exec executes the query that has been previously configured on the
// UpdateBuilder.
func (ub *UpdateBuilder) Exec() (sql.Result, error) {
r, err := ub.Table.Session.Exec(ub.sql)
if err != nil {
return nil, errors.Wrap(err, "select failed")
}
return r, nil
}
// Limit is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#UpdateBuilder.Limit
func (ub *UpdateBuilder) Limit(limit uint64) *UpdateBuilder {
ub.sql = ub.sql.Limit(limit)
return ub
}
// Offset is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#UpdateBuilder.Offset
func (ub *UpdateBuilder) Offset(offset uint64) *UpdateBuilder {
ub.sql = ub.sql.Offset(offset)
return ub
}
// OrderBy is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#UpdateBuilder.OrderBy
func (ub *UpdateBuilder) OrderBy(
orderBys ...string,
) *UpdateBuilder {
ub.sql = ub.sql.OrderBy(orderBys...)
return ub
}
// Prefix is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#UpdateBuilder.Prefix
func (ub *UpdateBuilder) Prefix(
sql string,
args ...interface{},
) *UpdateBuilder {
ub.sql = ub.sql.Prefix(sql, args...)
return ub
}
// Set is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#UpdateBuilder.Suffix
func (ub *UpdateBuilder) Set(column string, value interface{}) *UpdateBuilder {
ub.sql = ub.sql.Set(column, value)
return ub
}
// SetMap is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#UpdateBuilder.Suffix
func (ub *UpdateBuilder) SetMap(clauses map[string]interface{}) *UpdateBuilder {
ub.sql = ub.sql.SetMap(clauses)
return ub
}
// Suffix is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#UpdateBuilder.Suffix
func (ub *UpdateBuilder) Suffix(
sql string,
args ...interface{},
) *UpdateBuilder {
ub.sql = ub.sql.Suffix(sql, args...)
return ub
}
// Where is a passthrough call to the squirrel. See
// https://godoc.org/github.com/Masterminds/squirrel#UpdateBuilder.Where
func (ub *UpdateBuilder) Where(
pred interface{},
args ...interface{},
) *UpdateBuilder {
ub.sql = ub.sql.Where(pred, args...)
return ub
}