@@ -8,8 +8,12 @@ type UpdateStatement interface {
88 // Overrides the table name provided by the entity.
99 SetTable (table string ) UpdateStatement
1010
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
1317
1418 // SetWhere sets the where clause for the UPDATE statement.
1519 SetWhere (where string ) UpdateStatement
@@ -20,8 +24,11 @@ type UpdateStatement interface {
2024 // Table returns the table name for the UPDATE statement.
2125 Table () string
2226
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
2532
2633 // Where returns the where clause for the UPDATE statement.
2734 Where () string
@@ -39,10 +46,11 @@ func NewUpdateStatement(entity Entity) UpdateStatement {
3946
4047// updateStatement is the default implementation of the UpdateStatement interface.
4148type 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
4654}
4755
4856func (u * updateStatement ) SetTable (table string ) UpdateStatement {
@@ -51,8 +59,14 @@ func (u *updateStatement) SetTable(table string) UpdateStatement {
5159 return u
5260}
5361
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
5670
5771 return u
5872}
@@ -71,8 +85,12 @@ func (u *updateStatement) Table() string {
7185 return u .table
7286}
7387
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
7694}
7795
7896func (u * updateStatement ) Where () string {
0 commit comments