File tree Expand file tree Collapse file tree 3 files changed +30
-10
lines changed Expand file tree Collapse file tree 3 files changed +30
-10
lines changed Original file line number Diff line number Diff line change 1
1
run :
2
2
tests : true
3
- skip-dirs :
3
+
4
+ issues :
5
+ exclude-dirs :
4
6
- bin
5
7
- docs
6
8
- example
9
+ exclude-rules :
10
+ # Exclude some linters from running on tests files.
11
+ - path : _test\.go
12
+ linters :
13
+ - dupl
14
+ - unused
7
15
8
16
linters-settings :
9
17
errcheck :
10
- ignore : fmt:.*,[rR]ead|[wW]rite|[cC]lose,io:Copy
18
+ exclude-functions :
19
+ - fmt:.*
20
+ - " [rR]ead|[wW]rite|[cC]lose"
21
+ - io:Copy
11
22
12
23
linters :
13
24
disable-all : true
@@ -26,11 +37,3 @@ linters:
26
37
- prealloc
27
38
- unconvert
28
39
- unused
29
-
30
- issues :
31
- exclude-rules :
32
- # Exclude some linters from running on tests files.
33
- - path : _test\.go
34
- linters :
35
- - dupl
36
- - unused
Original file line number Diff line number Diff line change @@ -27,6 +27,16 @@ func WithUpdateReturningAll() UpdateOption {
27
27
}
28
28
}
29
29
30
+ func WithUpdateReturning (columns ... string ) UpdateOption {
31
+ return func (table exp.IdentifierExpression , s * goqu.UpdateDataset ) * goqu.UpdateDataset {
32
+ cols := make ([]any , 0 , len (columns ))
33
+ for _ , c := range columns {
34
+ cols = append (cols , table .Col (c ))
35
+ }
36
+ return s .Returning (cols ... )
37
+ }
38
+ }
39
+
30
40
func WithUpdateSet (value any ) UpdateOption {
31
41
return func (table exp.IdentifierExpression , s * goqu.UpdateDataset ) * goqu.UpdateDataset {
32
42
return s .Set (value )
Original file line number Diff line number Diff line change @@ -53,6 +53,13 @@ func TestBuildUpdate(t *testing.T) {
53
53
expectedQuery : `UPDATE "update_models" SET "int_field"=$1 RETURNING *` ,
54
54
expectedArgs : []interface {}{int64 (5 )},
55
55
},
56
+ {
57
+ name : "update_with_specific_returning" ,
58
+ dst : updateModel {IntField : 5 },
59
+ options : []goqux.UpdateOption {goqux .WithUpdateReturning ("int_field" , "another_col_name" )},
60
+ expectedQuery : `UPDATE "update_models" SET "int_field"=$1 RETURNING "update_models"."int_field", "update_models"."another_col_name"` ,
61
+ expectedArgs : []interface {}{int64 (5 )},
62
+ },
56
63
{
57
64
name : "update_with_zero_values" ,
58
65
dst : updateModel {IntField : 0 },
You can’t perform that action at this time.
0 commit comments