Skip to content

Commit 5b10515

Browse files
committed
remove options setters
1 parent 1324c47 commit 5b10515

File tree

7 files changed

+21
-59
lines changed

7 files changed

+21
-59
lines changed

mongo/collection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ func (coll *Collection) InsertOne(ctx context.Context, document interface{},
360360
imOpts.SetComment(ioOpts.Comment)
361361
}
362362
if ioOpts.BypassEmptyTsReplacement != nil {
363-
imOpts.SetBypassEmptyTsReplacement(*ioOpts.BypassEmptyTsReplacement)
363+
imOpts.BypassEmptyTsReplacement = ioOpts.BypassEmptyTsReplacement
364364
}
365365
res, err := coll.insert(ctx, []interface{}{document}, imOpts)
366366

mongo/integration/collection_test.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,10 @@ func TestBypassEmptyTsReplacement(t *testing.T) {
18771877
}
18781878
}
18791879

1880+
boolPtr := func(b bool) *bool {
1881+
return &b
1882+
}
1883+
18801884
mt.Run("insert one", func(mt *mtest.T) {
18811885
doc := bson.D{{"x", 42}}
18821886

@@ -1892,12 +1896,12 @@ func TestBypassEmptyTsReplacement(t *testing.T) {
18921896
},
18931897
{
18941898
"false",
1895-
options.InsertOne().SetBypassEmptyTsReplacement(false),
1899+
&options.InsertOneOptions{BypassEmptyTsReplacement: boolPtr(false)},
18961900
marshalValue(false),
18971901
},
18981902
{
18991903
"true",
1900-
options.InsertOne().SetBypassEmptyTsReplacement(true),
1904+
&options.InsertOneOptions{BypassEmptyTsReplacement: boolPtr(true)},
19011905
marshalValue(true),
19021906
},
19031907
}
@@ -1929,12 +1933,12 @@ func TestBypassEmptyTsReplacement(t *testing.T) {
19291933
},
19301934
{
19311935
"false",
1932-
options.InsertMany().SetBypassEmptyTsReplacement(false),
1936+
&options.InsertManyOptions{BypassEmptyTsReplacement: boolPtr(false)},
19331937
marshalValue(false),
19341938
},
19351939
{
19361940
"true",
1937-
options.InsertMany().SetBypassEmptyTsReplacement(true),
1941+
&options.InsertManyOptions{BypassEmptyTsReplacement: boolPtr(true)},
19381942
marshalValue(true),
19391943
},
19401944
}
@@ -1964,12 +1968,12 @@ func TestBypassEmptyTsReplacement(t *testing.T) {
19641968
},
19651969
{
19661970
"false",
1967-
options.Update().SetBypassEmptyTsReplacement(false),
1971+
&options.UpdateOptions{BypassEmptyTsReplacement: boolPtr(false)},
19681972
marshalValue(false),
19691973
},
19701974
{
19711975
"true",
1972-
options.Update().SetBypassEmptyTsReplacement(true),
1976+
&options.UpdateOptions{BypassEmptyTsReplacement: boolPtr(true)},
19731977
marshalValue(true),
19741978
},
19751979
}
@@ -1999,12 +2003,12 @@ func TestBypassEmptyTsReplacement(t *testing.T) {
19992003
},
20002004
{
20012005
"false",
2002-
options.Update().SetBypassEmptyTsReplacement(false),
2006+
&options.UpdateOptions{BypassEmptyTsReplacement: boolPtr(false)},
20032007
marshalValue(false),
20042008
},
20052009
{
20062010
"true",
2007-
options.Update().SetBypassEmptyTsReplacement(true),
2011+
&options.UpdateOptions{BypassEmptyTsReplacement: boolPtr(true)},
20082012
marshalValue(true),
20092013
},
20102014
}
@@ -2034,12 +2038,12 @@ func TestBypassEmptyTsReplacement(t *testing.T) {
20342038
},
20352039
{
20362040
"false",
2037-
options.Replace().SetBypassEmptyTsReplacement(false),
2041+
&options.ReplaceOptions{BypassEmptyTsReplacement: boolPtr(false)},
20382042
marshalValue(false),
20392043
},
20402044
{
20412045
"true",
2042-
options.Replace().SetBypassEmptyTsReplacement(true),
2046+
&options.ReplaceOptions{BypassEmptyTsReplacement: boolPtr(true)},
20432047
marshalValue(true),
20442048
},
20452049
}
@@ -2069,12 +2073,12 @@ func TestBypassEmptyTsReplacement(t *testing.T) {
20692073
},
20702074
{
20712075
"false",
2072-
options.FindOneAndUpdate().SetBypassEmptyTsReplacement(false),
2076+
&options.FindOneAndUpdateOptions{BypassEmptyTsReplacement: boolPtr(false)},
20732077
marshalValue(false),
20742078
},
20752079
{
20762080
"true",
2077-
options.FindOneAndUpdate().SetBypassEmptyTsReplacement(true),
2081+
&options.FindOneAndUpdateOptions{BypassEmptyTsReplacement: boolPtr(true)},
20782082
marshalValue(true),
20792083
},
20802084
}
@@ -2107,12 +2111,12 @@ func TestBypassEmptyTsReplacement(t *testing.T) {
21072111
},
21082112
{
21092113
"false",
2110-
options.FindOneAndReplace().SetBypassEmptyTsReplacement(false),
2114+
&options.FindOneAndReplaceOptions{BypassEmptyTsReplacement: boolPtr(false)},
21112115
marshalValue(false),
21122116
},
21132117
{
21142118
"true",
2115-
options.FindOneAndReplace().SetBypassEmptyTsReplacement(true),
2119+
&options.FindOneAndReplaceOptions{BypassEmptyTsReplacement: boolPtr(true)},
21162120
marshalValue(true),
21172121
},
21182122
}
@@ -2164,12 +2168,12 @@ func TestBypassEmptyTsReplacement(t *testing.T) {
21642168
},
21652169
{
21662170
"false",
2167-
options.BulkWrite().SetBypassEmptyTsReplacement(false),
2171+
&options.BulkWriteOptions{BypassEmptyTsReplacement: boolPtr(false)},
21682172
marshalValue(false),
21692173
},
21702174
{
21712175
"true",
2172-
options.BulkWrite().SetBypassEmptyTsReplacement(true),
2176+
&options.BulkWriteOptions{BypassEmptyTsReplacement: boolPtr(true)},
21732177
marshalValue(true),
21742178
},
21752179
}

mongo/options/bulkwriteoptions.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ func (b *BulkWriteOptions) SetLet(let interface{}) *BulkWriteOptions {
7171
return b
7272
}
7373

74-
// SetBypassEmptyTsReplacement sets the value for the BypassEmptyTsReplacement field.
75-
func (b *BulkWriteOptions) SetBypassEmptyTsReplacement(bypassEmptyTsReplacement bool) *BulkWriteOptions {
76-
b.BypassEmptyTsReplacement = &bypassEmptyTsReplacement
77-
return b
78-
}
79-
8074
// MergeBulkWriteOptions combines the given BulkWriteOptions instances into a single BulkWriteOptions in a last-one-wins
8175
// fashion.
8276
//

mongo/options/findoptions.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,6 @@ func (f *FindOneAndReplaceOptions) SetLet(let interface{}) *FindOneAndReplaceOpt
752752
return f
753753
}
754754

755-
// SetBypassEmptyTsReplacement sets the value for the BypassEmptyTsReplacement field.
756-
func (f *FindOneAndReplaceOptions) SetBypassEmptyTsReplacement(b bool) *FindOneAndReplaceOptions {
757-
f.BypassEmptyTsReplacement = &b
758-
return f
759-
}
760-
761755
// MergeFindOneAndReplaceOptions combines the given FindOneAndReplaceOptions instances into a single
762756
// FindOneAndReplaceOptions in a last-one-wins fashion.
763757
//
@@ -950,12 +944,6 @@ func (f *FindOneAndUpdateOptions) SetLet(let interface{}) *FindOneAndUpdateOptio
950944
return f
951945
}
952946

953-
// SetBypassEmptyTsReplacement sets the value for the BypassEmptyTsReplacement field.
954-
func (f *FindOneAndUpdateOptions) SetBypassEmptyTsReplacement(b bool) *FindOneAndUpdateOptions {
955-
f.BypassEmptyTsReplacement = &b
956-
return f
957-
}
958-
959947
// MergeFindOneAndUpdateOptions combines the given FindOneAndUpdateOptions instances into a single
960948
// FindOneAndUpdateOptions in a last-one-wins fashion.
961949
//

mongo/options/insertoptions.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ func (ioo *InsertOneOptions) SetComment(comment interface{}) *InsertOneOptions {
4242
return ioo
4343
}
4444

45-
// SetBypassEmptyTsReplacement sets the value for the BypassEmptyTsReplacement field.
46-
func (ioo *InsertOneOptions) SetBypassEmptyTsReplacement(b bool) *InsertOneOptions {
47-
ioo.BypassEmptyTsReplacement = &b
48-
return ioo
49-
}
50-
5145
// MergeInsertOneOptions combines the given InsertOneOptions instances into a single InsertOneOptions in a last-one-wins
5246
// fashion.
5347
//
@@ -120,12 +114,6 @@ func (imo *InsertManyOptions) SetOrdered(b bool) *InsertManyOptions {
120114
return imo
121115
}
122116

123-
// SetBypassEmptyTsReplacement sets the value for the BypassEmptyTsReplacement field.
124-
func (imo *InsertManyOptions) SetBypassEmptyTsReplacement(b bool) *InsertManyOptions {
125-
imo.BypassEmptyTsReplacement = &b
126-
return imo
127-
}
128-
129117
// MergeInsertManyOptions combines the given InsertManyOptions instances into a single InsertManyOptions in a last one
130118
// wins fashion.
131119
//

mongo/options/replaceoptions.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ func (ro *ReplaceOptions) SetLet(l interface{}) *ReplaceOptions {
8989
return ro
9090
}
9191

92-
// SetBypassEmptyTsReplacement sets the value for the BypassEmptyTsReplacement field.
93-
func (ro *ReplaceOptions) SetBypassEmptyTsReplacement(b bool) *ReplaceOptions {
94-
ro.BypassEmptyTsReplacement = &b
95-
return ro
96-
}
97-
9892
// MergeReplaceOptions combines the given ReplaceOptions instances into a single ReplaceOptions in a last-one-wins
9993
// fashion.
10094
//

mongo/options/updateoptions.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ func (uo *UpdateOptions) SetLet(l interface{}) *UpdateOptions {
100100
return uo
101101
}
102102

103-
// SetBypassEmptyTsReplacement sets the value for the BypassEmptyTsReplacement field.
104-
func (uo *UpdateOptions) SetBypassEmptyTsReplacement(b bool) *UpdateOptions {
105-
uo.BypassEmptyTsReplacement = &b
106-
return uo
107-
}
108-
109103
// MergeUpdateOptions combines the given UpdateOptions instances into a single UpdateOptions in a last-one-wins fashion.
110104
//
111105
// Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a

0 commit comments

Comments
 (0)