diff options
author | Mathias Stearn <mathias@10gen.com> | 2015-06-10 16:39:05 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2015-06-29 19:23:14 -0400 |
commit | 6acbfbba4f2e9e33221d71f2241642b6f9d2e479 (patch) | |
tree | c9eef3b9a460e68c796fc7a1cafd5ac74331d123 /src/mongo/shell | |
parent | 96a9efeeee87df94c9c5fa7bdf1f1d2d93f234d4 (diff) | |
download | mongo-6acbfbba4f2e9e33221d71f2241642b6f9d2e479.tar.gz |
SERVER-18917 make DBCommandCursor::next() shell method not require calling hasNext() first
In the current interface between the shell and the c++ driver, hasNext() is
what fetches the results from the server if at the end of the current batch.
next() just reads from the current batch. DBQuery smooths over this weirdness
by calling hasNext() from next() and throwing if it returns false.
DBCommandCursor should do the same.
Diffstat (limited to 'src/mongo/shell')
-rw-r--r-- | src/mongo/shell/query.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/mongo/shell/query.js b/src/mongo/shell/query.js index 4852763a004..8bea09ca1a0 100644 --- a/src/mongo/shell/query.js +++ b/src/mongo/shell/query.js @@ -530,6 +530,8 @@ DBCommandCursor.prototype.next = function() { return this._firstBatch.pop(); } else { + if (!this._cursor.hasNext()) throw Error("error hasNext: false"); + var ret = this._cursor.next(); if ( ret.$err ) throw Error( "error: " + tojson( ret ) ); |