...
1 package exp
2
3 type (
4 doNothingConflict struct{}
5
6
7 conflictUpdate struct {
8 target string
9 update interface{}
10 whereClause ExpressionList
11 }
12 )
13
14
15
16 func NewDoNothingConflictExpression() ConflictExpression {
17 return &doNothingConflict{}
18 }
19
20 func (c doNothingConflict) Expression() Expression {
21 return c
22 }
23
24 func (c doNothingConflict) Clone() Expression {
25 return c
26 }
27
28 func (c doNothingConflict) Action() ConflictAction {
29 return DoNothingConflictAction
30 }
31
32
33
34
35
36
37
38
39 func NewDoUpdateConflictExpression(target string, update interface{}) ConflictUpdateExpression {
40 return &conflictUpdate{target: target, update: update}
41 }
42
43 func (c conflictUpdate) Expression() Expression {
44 return c
45 }
46
47 func (c conflictUpdate) Clone() Expression {
48 return &conflictUpdate{
49 target: c.target,
50 update: c.update,
51 whereClause: c.whereClause.Clone().(ExpressionList),
52 }
53 }
54
55 func (c conflictUpdate) Action() ConflictAction {
56 return DoUpdateConflictAction
57 }
58
59
60
61 func (c conflictUpdate) TargetColumn() string {
62 return c.target
63 }
64
65
66
67 func (c conflictUpdate) Update() interface{} {
68 return c.update
69 }
70
71
72
73 func (c *conflictUpdate) Where(expressions ...Expression) ConflictUpdateExpression {
74 if c.whereClause == nil {
75 c.whereClause = NewExpressionList(AndType, expressions...)
76 } else {
77 c.whereClause = c.whereClause.Append(expressions...)
78 }
79 return c
80 }
81
82
83
84 func (c *conflictUpdate) WhereClause() ExpressionList {
85 return c.whereClause
86 }
87
View as plain text