Skip to content

Commit 153ea1d

Browse files
authored
GODRIVER-3433 Restore SetOplogReplay. (#1901)
1 parent 1ada5fa commit 153ea1d

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

internal/integration/collection_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@ func TestCollection(t *testing.T) {
11651165
SetHint(indexName).
11661166
SetMax(bson.D{{"x", int32(5)}}).
11671167
SetMin(bson.D{{"x", int32(0)}}).
1168+
SetOplogReplay(false).
11681169
SetProjection(bson.D{{"x", int32(1)}}).
11691170
SetReturnKey(false).
11701171
SetShowRecordID(false).
@@ -1186,6 +1187,7 @@ func TestCollection(t *testing.T) {
11861187
AppendString("hint", indexName).
11871188
StartDocument("max").AppendInt32("x", 5).FinishDocument().
11881189
StartDocument("min").AppendInt32("x", 0).FinishDocument().
1190+
AppendBoolean("oplogReplay", false).
11891191
StartDocument("projection").AppendInt32("x", 1).FinishDocument().
11901192
AppendBoolean("returnKey", false).
11911193
AppendBoolean("showRecordId", false).

internal/integration/unified/collection_operation_execution.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,8 @@ func createFindCursor(ctx context.Context, operation *operation) (*cursorResult,
14711471
opts.SetMin(val.Document())
14721472
case "noCursorTimeout":
14731473
opts.SetNoCursorTimeout(val.Boolean())
1474+
case "oplogReplay":
1475+
opts.SetOplogReplay(val.Boolean())
14741476
case "projection":
14751477
opts.SetProjection(val.Document())
14761478
case "returnKey":

mongo/collection.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,9 @@ func (coll *Collection) find(
14651465
if args.NoCursorTimeout != nil {
14661466
op.NoCursorTimeout(*args.NoCursorTimeout)
14671467
}
1468+
if args.OplogReplay != nil {
1469+
op.OplogReplay(*args.OplogReplay)
1470+
}
14681471
if args.Projection != nil {
14691472
proj, err := marshal(args.Projection, coll.bsonOpts, coll.registry)
14701473
if err != nil {
@@ -1518,6 +1521,7 @@ func newFindArgsFromFindOneArgs(args *options.FindOneOptions) *options.FindOptio
15181521
v.Hint = args.Hint
15191522
v.Max = args.Max
15201523
v.Min = args.Min
1524+
v.OplogReplay = args.OplogReplay
15211525
v.Projection = args.Projection
15221526
v.ReturnKey = args.ReturnKey
15231527
v.ShowRecordID = args.ShowRecordID

mongo/options/findoptions.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type FindOptions struct {
2222
Max interface{}
2323
MaxAwaitTime *time.Duration
2424
Min interface{}
25+
OplogReplay *bool
2526
Projection interface{}
2627
ReturnKey *bool
2728
ShowRecordID *bool
@@ -200,6 +201,19 @@ func (f *FindOptionsBuilder) SetNoCursorTimeout(b bool) *FindOptionsBuilder {
200201
return f
201202
}
202203

204+
// SetOplogReplay sets the value for the OplogReplay field. OplogReplay is for internal
205+
// replication use only and should not be set.
206+
//
207+
// Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by
208+
// the server if it is set.
209+
func (f *FindOptionsBuilder) SetOplogReplay(b bool) *FindOptionsBuilder {
210+
f.Opts = append(f.Opts, func(opts *FindOptions) error {
211+
opts.OplogReplay = &b
212+
return nil
213+
})
214+
return f
215+
}
216+
203217
// SetProjection sets the value for the Projection field. Projection is a document describing
204218
// which fields will be included in the documents returned by the Find operation. The
205219
// default value is nil, which means all fields will be included.
@@ -265,6 +279,7 @@ type FindOneOptions struct {
265279
Hint interface{}
266280
Max interface{}
267281
Min interface{}
282+
OplogReplay *bool
268283
Projection interface{}
269284
ReturnKey *bool
270285
ShowRecordID *bool
@@ -354,6 +369,19 @@ func (f *FindOneOptionsBuilder) SetMin(min interface{}) *FindOneOptionsBuilder {
354369
return f
355370
}
356371

372+
// SetOplogReplay sets the value for the OplogReplay field. OplogReplay is for internal
373+
// replication use only and should not be set.
374+
//
375+
// Deprecated: This option has been deprecated in MongoDB version 4.4 and will be ignored by
376+
// the server if it is set.
377+
func (f *FindOneOptionsBuilder) SetOplogReplay(b bool) *FindOneOptionsBuilder {
378+
f.Opts = append(f.Opts, func(opts *FindOneOptions) error {
379+
opts.OplogReplay = &b
380+
return nil
381+
})
382+
return f
383+
}
384+
357385
// SetProjection sets the value for the Projection field. Sets a document describing which fields
358386
// will be included in the document returned by the operation. The default value is nil, which
359387
// means all fields will be included.

0 commit comments

Comments
 (0)