Skip to content

Commit fd9e1c0

Browse files
author
Isabella Siu
committed
GODRIVER-281 Remove snapshot option
Change-Id: Iedaad613e9e6d023040215fd7650c994a36e6147
1 parent cbffa77 commit fd9e1c0

File tree

6 files changed

+4
-73
lines changed

6 files changed

+4
-73
lines changed

core/option/options.go

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ var (
236236
_ FindOptioner = (*OptReturnKey)(nil)
237237
_ FindOptioner = (*OptShowRecordID)(nil)
238238
_ FindOptioner = (*OptSkip)(nil)
239-
_ FindOptioner = (*OptSnapshot)(nil)
240239
_ FindOptioner = (*OptSort)(nil)
241240
_ FindOneOptioner = (*OptAllowPartialResults)(nil)
242241
_ FindOneOptioner = (*OptBatchSize)(nil)
@@ -254,7 +253,6 @@ var (
254253
_ FindOneOptioner = (*OptReturnKey)(nil)
255254
_ FindOneOptioner = (*OptShowRecordID)(nil)
256255
_ FindOneOptioner = (*OptSkip)(nil)
257-
_ FindOneOptioner = (*OptSnapshot)(nil)
258256
_ FindOneOptioner = (*OptSort)(nil)
259257
_ InsertManyOptioner = (*OptBypassDocumentValidation)(nil)
260258
_ InsertManyOptioner = (*OptOrdered)(nil)
@@ -862,23 +860,6 @@ func (opt OptSkip) String() string {
862860
return "OptSkip: " + strconv.FormatInt(int64(opt), 10)
863861
}
864862

865-
// OptSnapshot is for internal use.
866-
type OptSnapshot bool
867-
868-
// Option implements the Optioner interface.
869-
func (opt OptSnapshot) Option(d *bson.Document) error {
870-
d.Append(bson.EC.Boolean("snapshot", bool(opt)))
871-
return nil
872-
}
873-
874-
func (OptSnapshot) findOption() {}
875-
func (OptSnapshot) findOneOption() {}
876-
877-
// String implements the Stringer interface.
878-
func (opt OptSnapshot) String() string {
879-
return "OptSnapshot: " + strconv.FormatBool(bool(opt))
880-
}
881-
882863
// OptSort is for internal use.
883864
type OptSort struct {
884865
Registry *bsoncodec.Registry

mongo/findopt/find.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,6 @@ func (fb *FindBundle) Skip(i int64) *FindBundle {
241241
return bundle
242242
}
243243

244-
// Snapshot adds an option to prevent the cursor from returning a document more than once because of an
245-
// intervening write operation.
246-
func (fb *FindBundle) Snapshot(b bool) *FindBundle {
247-
bundle := &FindBundle{
248-
option: Snapshot(b),
249-
next: fb,
250-
}
251-
252-
return bundle
253-
}
254-
255244
// Sort adds an option to specify the order in which to return results.
256245
func (fb *FindBundle) Sort(sort interface{}) *FindBundle {
257246
bundle := &FindBundle{

mongo/findopt/findopt.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ var (
4040
_ Find = (*OptReturnKey)(nil)
4141
_ Find = (*OptShowRecordID)(nil)
4242
_ Find = (*OptSkip)(nil)
43-
_ Find = (*OptSnapshot)(nil)
4443
_ Find = (*OptSort)(nil)
4544
_ One = (*OneBundle)(nil)
4645
_ One = (*OptAllowPartialResults)(nil)
@@ -60,7 +59,6 @@ var (
6059
_ One = (*OptReturnKey)(nil)
6160
_ One = (*OptShowRecordID)(nil)
6261
_ One = (*OptSkip)(nil)
63-
_ One = (*OptSnapshot)(nil)
6462
_ One = (*OptSort)(nil)
6563
_ ReplaceOne = (*ReplaceOneBundle)(nil)
6664
_ ReplaceOne = (*OptBypassDocumentValidation)(nil)
@@ -213,13 +211,6 @@ func Skip(i int64) OptSkip {
213211
return OptSkip(i)
214212
}
215213

216-
// Snapshot prevents the cursor from returning a document more than once because of an
217-
// intervening write operation.
218-
// Find, One
219-
func Snapshot(b bool) OptSnapshot {
220-
return OptSnapshot(b)
221-
}
222-
223214
// Sort specifies the order in which to return results.
224215
// Find, One, DeleteOne, ReplaceOne, UpdateOne
225216
func Sort(sort interface{}) OptSort {
@@ -638,23 +629,6 @@ func (opt OptSkip) ConvertFindOneOption() option.FindOptioner {
638629
return option.OptSkip(opt)
639630
}
640631

641-
// OptSnapshot prevents the cursor from returning a document more than once because of an
642-
// intervening write operation.
643-
type OptSnapshot option.OptSnapshot
644-
645-
func (OptSnapshot) find() {}
646-
func (OptSnapshot) one() {}
647-
648-
// ConvertFindOption implements the Find interface.
649-
func (opt OptSnapshot) ConvertFindOption() option.FindOptioner {
650-
return option.OptSnapshot(opt)
651-
}
652-
653-
// ConvertFindOneOption implements the One interface.
654-
func (opt OptSnapshot) ConvertFindOneOption() option.FindOptioner {
655-
return option.OptSnapshot(opt)
656-
}
657-
658632
// OptSort specifies the order in which to return results.
659633
type OptSort option.OptSort
660634

mongo/findopt/findopt_many_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ func TestFindOpt(t *testing.T) {
181181
ReturnKey(true),
182182
ShowRecordID(false),
183183
Skip(50),
184-
Snapshot(false),
185184
Sort("sort for find"),
186185
}
187186
params := make([]Find, len(opts))
@@ -206,14 +205,14 @@ func TestFindOpt(t *testing.T) {
206205

207206
t.Run("Nil Option Bundle", func(t *testing.T) {
208207
sess := FindSessionOpt{}
209-
opts, _, err := BundleFind(Snapshot(true), BundleFind(nil), sess, nil).unbundle()
208+
opts, _, err := BundleFind(OptAllowPartialResults(true), BundleFind(nil), sess, nil).unbundle()
210209
testhelpers.RequireNil(t, err, "got non-nil error from unbundle: %s", err)
211210

212211
if len(opts) != 1 {
213212
t.Errorf("expected bundle length 1. got: %d", len(opts))
214213
}
215214

216-
opts, _, err = BundleFind(nil, sess, BundleFind(nil), Snapshot(true)).unbundle()
215+
opts, _, err = BundleFind(nil, sess, BundleFind(nil), OptAllowPartialResults(true)).unbundle()
217216
testhelpers.RequireNil(t, err, "got non-nil error from unbundle: %s", err)
218217

219218
if len(opts) != 1 {

mongo/findopt/findopt_one_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ func TestFindOneOpt(t *testing.T) {
180180
ReturnKey(true),
181181
ShowRecordID(false),
182182
Skip(50),
183-
Snapshot(false),
184183
Sort("sort for find"),
185184
}
186185
params := make([]One, len(opts))
@@ -205,14 +204,14 @@ func TestFindOneOpt(t *testing.T) {
205204

206205
t.Run("Nil Option Bundle", func(t *testing.T) {
207206
sess := FindSessionOpt{}
208-
opts, _, err := BundleOne(Snapshot(true), BundleOne(nil), sess, nil).unbundle()
207+
opts, _, err := BundleOne(OptAllowPartialResults(true), BundleOne(nil), sess, nil).unbundle()
209208
testhelpers.RequireNil(t, err, "got non-nil error from unbundle: %s", err)
210209

211210
if len(opts) != 1 {
212211
t.Errorf("expected bundle length 1. got: %d", len(opts))
213212
}
214213

215-
opts, _, err = BundleOne(nil, sess, BundleOne(nil), Snapshot(true)).unbundle()
214+
opts, _, err = BundleOne(nil, sess, BundleOne(nil), OptAllowPartialResults(true)).unbundle()
216215
testhelpers.RequireNil(t, err, "got non-nil error from unbundle: %s", err)
217216

218217
if len(opts) != 1 {

mongo/findopt/one.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,6 @@ func (ob *OneBundle) Skip(i int64) *OneBundle {
231231
return bundle
232232
}
233233

234-
// Snapshot adds an option to prevent the server from returning multiple copies because of an intervening
235-
// write operation
236-
func (ob *OneBundle) Snapshot(b bool) *OneBundle {
237-
bundle := &OneBundle{
238-
option: Snapshot(b),
239-
next: ob,
240-
}
241-
242-
return bundle
243-
}
244-
245234
// Sort adds an option to specify the order in which to return results.
246235
func (ob *OneBundle) Sort(sort interface{}) *OneBundle {
247236
bundle := &OneBundle{

0 commit comments

Comments
 (0)