@@ -8,8 +8,12 @@ type UpdateStatement interface {
8
8
// Overrides the table name provided by the entity.
9
9
SetTable (table string ) UpdateStatement
10
10
11
- // SetSet sets the set clause for the UPDATE statement.
12
- SetSet (set string ) UpdateStatement
11
+ // SetColumns sets the columns to be updated.
12
+ SetColumns (columns ... string ) UpdateStatement
13
+
14
+ // SetExcludedColumns sets the columns to be excluded from the UPDATE statement.
15
+ // Excludes also columns set by SetColumns.
16
+ SetExcludedColumns (columns ... string ) UpdateStatement
13
17
14
18
// SetWhere sets the where clause for the UPDATE statement.
15
19
SetWhere (where string ) UpdateStatement
@@ -20,8 +24,11 @@ type UpdateStatement interface {
20
24
// Table returns the table name for the UPDATE statement.
21
25
Table () string
22
26
23
- // Set returns the set clause for the UPDATE statement.
24
- Set () string
27
+ // Columns returns the columns to be updated.
28
+ Columns () []string
29
+
30
+ // ExcludedColumns returns the columns to be excluded from the UPDATE statement.
31
+ ExcludedColumns () []string
25
32
26
33
// Where returns the where clause for the UPDATE statement.
27
34
Where () string
@@ -39,10 +46,11 @@ func NewUpdateStatement(entity Entity) UpdateStatement {
39
46
40
47
// updateStatement is the default implementation of the UpdateStatement interface.
41
48
type updateStatement struct {
42
- entity Entity
43
- table string
44
- set string
45
- where string
49
+ entity Entity
50
+ table string
51
+ columns []string
52
+ excludedColumns []string
53
+ where string
46
54
}
47
55
48
56
func (u * updateStatement ) SetTable (table string ) UpdateStatement {
@@ -51,8 +59,14 @@ func (u *updateStatement) SetTable(table string) UpdateStatement {
51
59
return u
52
60
}
53
61
54
- func (u * updateStatement ) SetSet (set string ) UpdateStatement {
55
- u .set = set
62
+ func (u * updateStatement ) SetColumns (columns ... string ) UpdateStatement {
63
+ u .columns = columns
64
+
65
+ return u
66
+ }
67
+
68
+ func (u * updateStatement ) SetExcludedColumns (columns ... string ) UpdateStatement {
69
+ u .excludedColumns = columns
56
70
57
71
return u
58
72
}
@@ -71,8 +85,12 @@ func (u *updateStatement) Table() string {
71
85
return u .table
72
86
}
73
87
74
- func (u * updateStatement ) Set () string {
75
- return u .set
88
+ func (u * updateStatement ) Columns () []string {
89
+ return u .columns
90
+ }
91
+
92
+ func (u * updateStatement ) ExcludedColumns () []string {
93
+ return u .excludedColumns
76
94
}
77
95
78
96
func (u * updateStatement ) Where () string {
0 commit comments