summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Storch <david.storch@10gen.com>2016-02-05 16:30:44 -0500
committerDavid Storch <david.storch@10gen.com>2016-02-08 13:06:43 -0500
commiteeac75151395b523459833aaaa34d0fe2f2f7748 (patch)
treeac07c2ac3aec9a08ae15b09106432cf3f5962c97
parent50e97d09553b99b82f29c370d7d3008f037c5b10 (diff)
downloadmongo-eeac75151395b523459833aaaa34d0fe2f2f7748.tar.gz
SERVER-22440 fix shell to resolve readMode correctly on first .find() operation
-rw-r--r--src/mongo/shell/mongo.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/mongo/shell/mongo.js b/src/mongo/shell/mongo.js
index 3dd44fee978..68bc0ac54d8 100644
--- a/src/mongo/shell/mongo.js
+++ b/src/mongo/shell/mongo.js
@@ -312,16 +312,14 @@ Mongo.prototype.forceReadMode = function(mode) {
* and OP_GET_MORE, or "compatibility" for detecting based on wire version).
*/
Mongo.prototype.readMode = function() {
- if (this._readMode !== "compatibility") {
- if ("_readMode" in this) {
- // We already have determined our read mode. Just return it.
- return this._readMode;
- }
+ // Get the readMode from the shell params if we don't have one yet.
+ if (typeof _readMode === "function" && !this.hasOwnProperty("_readMode")) {
+ this._readMode = _readMode();
+ }
- // Get the readMode from the shell params.
- if (typeof _readMode === "function") {
- this._readMode = _readMode();
- }
+ if (this.hasOwnProperty("_readMode") && this._readMode !== "compatibility") {
+ // We already have determined our read mode. Just return it.
+ return this._readMode;
}
else {
// We're in compatibility mode. Determine whether the server supports the find/getMore