diff --git a/arangod/MMFiles/MMFilesPrimaryIndex.cpp b/arangod/MMFiles/MMFilesPrimaryIndex.cpp index 401112739e..d0c57ed1f5 100644 --- a/arangod/MMFiles/MMFilesPrimaryIndex.cpp +++ b/arangod/MMFiles/MMFilesPrimaryIndex.cpp @@ -119,12 +119,9 @@ bool MMFilesPrimaryIndexIterator::next(TokenCallback const& cb, size_t limit) { if (result) { cb(MMFilesToken{result.revisionId()}); --limit; - } else { - // We are done - return false; } } - return true; + return _iterator.valid(); } void MMFilesPrimaryIndexIterator::reset() { _iterator.reset(); } diff --git a/arangod/VocBase/SingleServerTraverser.cpp b/arangod/VocBase/SingleServerTraverser.cpp index f9e9286b99..ce82ebfd5e 100644 --- a/arangod/VocBase/SingleServerTraverser.cpp +++ b/arangod/VocBase/SingleServerTraverser.cpp @@ -75,10 +75,9 @@ bool SingleServerEdgeCursor::next(std::vector& result, if (_currentCursor == _cursors.size()) { return false; } - _cachePos++; if (_cachePos < _cache.size()) { LogicalCollection* collection = _cursors[_currentCursor][_currentSubCursor]->collection(); - if (collection->readDocument(_trx, *_mmdr, _cache[_cachePos])) { + if (collection->readDocument(_trx, *_mmdr, _cache[_cachePos++])) { result.emplace_back(_mmdr->vpack()); } if (_internalCursorMapping != nullptr) { @@ -132,7 +131,7 @@ bool SingleServerEdgeCursor::next(std::vector& result, TRI_ASSERT(_cachePos < _cache.size()); LogicalCollection* collection = cursor->collection(); - if (collection->readDocument(_trx, *_mmdr, _cache[_cachePos])) { + if (collection->readDocument(_trx, *_mmdr, _cache[_cachePos++])) { result.emplace_back(_mmdr->vpack()); } if (_internalCursorMapping != nullptr) { diff --git a/js/server/tests/aql/aql-primary-index-cluster.js b/js/server/tests/aql/aql-primary-index-cluster.js index 42d0904da4..4c03314984 100644 --- a/js/server/tests/aql/aql-primary-index-cluster.js +++ b/js/server/tests/aql/aql-primary-index-cluster.js @@ -171,6 +171,25 @@ function explainSuite () { ] }; assertEqual([ 1, 2, 3], AQL_EXECUTE(query, bindParams).json); + }, + + testInvalidValuesInINFilter : function () { + var query = "FOR i IN " + cn + " FILTER i._id IN @idList SORT i.value RETURN i.value"; + var bindParams = { + idList: [ + null, + cn + "/testkey1", // Find this + "blub/bla", + "noKey", + cn + "/testkey2", // And this + 123456, + { "the": "foxx", "is": "wrapped", "in":"objects"}, + [15, "man", "on", "the", "dead", "mans", "chest"], + cn + "/testkey3" // And this + ] + }; + require("internal").db._explain(query, bindParams); + assertEqual([ 1, 2, 3], AQL_EXECUTE(query, bindParams).json); } }; } diff --git a/js/server/tests/aql/aql-primary-index-noncluster.js b/js/server/tests/aql/aql-primary-index-noncluster.js index 7e2062b025..569eb60958 100644 --- a/js/server/tests/aql/aql-primary-index-noncluster.js +++ b/js/server/tests/aql/aql-primary-index-noncluster.js @@ -171,8 +171,25 @@ function explainSuite () { ] }; assertEqual([ 1, 2, 3], AQL_EXECUTE(query, bindParams).json); - } + }, + testInvalidValuesInCondition : function () { + var query = "FOR i IN " + cn + " FILTER i._id IN @idList SORT i.value RETURN i.value"; + var bindParams = { + idList: [ + null, + cn + "/testkey1", // Find this + "blub/bla", + "noKey", + cn + "/testkey2", // And this + 123456, + { "the": "foxx", "is": "wrapped", "in":"objects"}, + [15, "man", "on", "the", "dead", "mans", "chest"], + cn + "/testkey3" // And this + ] + }; + assertEqual([ 1, 2, 3], AQL_EXECUTE(query, bindParams).json); + } }; }