Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2973,6 +2973,13 @@ func (q *Query) SetMaxTime(d time.Duration) *Query {
return q
}

func (q *Query) AllowPartial() *Query {
q.m.Lock()
q.op.AllowPartial()
q.m.Unlock()
return q
}

// Snapshot will force the performed query to make use of an available
// index on the _id field to prevent the same document from being returned
// more than once in a single iteration. This might happen without this
Expand Down Expand Up @@ -3149,18 +3156,19 @@ func prepareFindOp(socket *mongoSocket, op *queryOp, limit int32) bool {
}

find := findCmd{
Collection: op.collection[nameDot+1:],
Filter: op.query,
Projection: op.selector,
Sort: op.options.OrderBy,
Skip: op.skip,
Limit: limit,
MaxTimeMS: op.options.MaxTimeMS,
MaxScan: op.options.MaxScan,
Hint: op.options.Hint,
Comment: op.options.Comment,
Snapshot: op.options.Snapshot,
OplogReplay: op.flags&flagLogReplay != 0,
Collection: op.collection[nameDot+1:],
Filter: op.query,
Projection: op.selector,
Sort: op.options.OrderBy,
Skip: op.skip,
Limit: limit,
MaxTimeMS: op.options.MaxTimeMS,
MaxScan: op.options.MaxScan,
Hint: op.options.Hint,
Comment: op.options.Comment,
Snapshot: op.options.Snapshot,
OplogReplay: op.flags&flagLogReplay != 0,
AllowPartialResults: op.flags&flagPartial != 0,
}
if op.limit < 0 {
find.BatchSize = -op.limit
Expand Down
6 changes: 6 additions & 0 deletions socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ const (
flagLogReplay
flagNoCursorTimeout
flagAwaitData
flagExhaust
flagPartial
)

type queryOp struct {
Expand Down Expand Up @@ -93,6 +95,10 @@ type queryWrapper struct {
Comment string "$comment,omitempty"
}

func (op *queryOp) AllowPartial() {
op.flags |= flagPartial
}

func (op *queryOp) finalQuery(socket *mongoSocket) interface{} {
if op.flags&flagSlaveOk != 0 && socket.ServerInfo().Mongos {
var modeName string
Expand Down