Skip to content

Commit 35e91c3

Browse files
author
Divjot Arora
committed
Legacy operations bug fixes.
GODRIVER-1322 Change-Id: I63682138c3238986534cfe6b420c67a169a2e7bd
1 parent 84ddf5a commit 35e91c3

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

mongo/operation_legacy_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,10 @@ func TestOperationLegacy(t *testing.T) {
259259
{"hint", "hintFoo"},
260260
{"limit", int64(5)},
261261
{"max", maxDoc},
262-
{"maxScan", int64(100)},
263262
{"maxTimeMS", int64(10000)},
264263
{"min", minDoc},
265264
{"noCursorTimeout", true},
266-
{"oplogReply", true},
265+
{"oplogReplay", true},
267266
{"projection", projection},
268267
{"returnKey", false},
269268
{"showRecordId", false},
@@ -287,7 +286,6 @@ func TestOperationLegacy(t *testing.T) {
287286
{"$comment", "hello"},
288287
{"$hint", "hintFoo"},
289288
{"$max", maxDoc},
290-
{"$maxScan", int64(100)},
291289
{"$maxTimeMS", int64(10000)},
292290
{"$min", minDoc},
293291
{"$returnKey", false},

mongo/options/indexoptions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func MergeListIndexesOptions(opts ...*ListIndexesOptions) *ListIndexesOptions {
105105
if opt == nil {
106106
continue
107107
}
108+
if opt.BatchSize != nil {
109+
c.BatchSize = opt.BatchSize
110+
}
108111
if opt.MaxTime != nil {
109112
c.MaxTime = opt.MaxTime
110113
}

x/mongo/driver/operation_legacy.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ func (op Operation) createLegacyFindWireMessage(dst []byte, desc description.Sel
107107
optsElems = bsoncore.AppendValueElement(optsElems, "$hint", elem.Value())
108108
case "comment":
109109
optsElems = bsoncore.AppendValueElement(optsElems, "$comment", elem.Value())
110-
case "maxScan":
111-
optsElems = bsoncore.AppendValueElement(optsElems, "$maxScan", elem.Value())
112110
case "max":
113111
optsElems = bsoncore.AppendValueElement(optsElems, "$max", elem.Value())
114112
case "min":
@@ -141,7 +139,7 @@ func (op Operation) createLegacyFindWireMessage(dst []byte, desc description.Sel
141139
flags |= wiremessage.TailableCursor
142140
case "awaitData":
143141
flags |= wiremessage.AwaitData
144-
case "oplogReply":
142+
case "oplogReplay":
145143
flags |= wiremessage.OplogReplay
146144
case "noCursorTimeout":
147145
flags |= wiremessage.NoCursorTimeout
@@ -560,8 +558,12 @@ func (op Operation) createLegacyListIndexesWiremessage(dst []byte, desc descript
560558
switch elem.Key() {
561559
case "listIndexes":
562560
filterCollName = elem.Value().StringValue()
563-
case "batchSize":
564-
batchSize = elem.Value().Int32()
561+
case "cursor":
562+
// the batchSize option is embedded in a cursor subdocument
563+
cursorDoc := elem.Value().Document()
564+
if val, err := cursorDoc.LookupErr("batchSize"); err == nil {
565+
batchSize = val.Int32()
566+
}
565567
case "maxTimeMS":
566568
optsElems = bsoncore.AppendValueElement(optsElems, "$maxTimeMS", elem.Value())
567569
}

0 commit comments

Comments
 (0)