Skip to content

Commit

Permalink
SERVER-17544 make $where work in the new mongos read path
Browse files Browse the repository at this point in the history
  • Loading branch information
dstorch committed Aug 13, 2015
1 parent 870efac commit 2f7b99c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions jstests/sharding/find_getmore_cmd.js
Expand Up @@ -79,5 +79,13 @@
assert.eq(cmdRes.cursor.firstBatch.length, 1);
assert.eq(cmdRes.cursor.firstBatch[0], {_id: -5});

// A predicate with $where.
cmdRes = db.runCommand({find: coll.getName(), filter: {$where: "this._id == 5"}});
assert.commandWorked(cmdRes);
assert.eq(cmdRes.cursor.id, NumberLong(0));
assert.eq(cmdRes.cursor.ns, coll.getFullName());
assert.eq(cmdRes.cursor.firstBatch.length, 1);
assert.eq(cmdRes.cursor.firstBatch[0], {_id: 5});

st.stop();
})();
2 changes: 1 addition & 1 deletion src/mongo/s/commands/cluster_find_cmd.cpp
Expand Up @@ -168,7 +168,7 @@ class ClusterFindCmd : public Command {
return appendCommandStatus(result, lpq.getStatus());
}

auto cq = CanonicalQuery::canonicalize(lpq.getValue().release());
auto cq = CanonicalQuery::canonicalize(lpq.getValue().release(), WhereCallbackNoop());
if (!cq.isOK()) {
return appendCommandStatus(result, cq.getStatus());
}
Expand Down
6 changes: 6 additions & 0 deletions src/mongo/s/d_state.cpp
Expand Up @@ -229,6 +229,12 @@ bool shardVersionOk(OperationContext* txn,
ChunkVersion& received,
ChunkVersion& wanted) {
Client* client = txn->getClient();

// Operations using the DBDirectClient are unversioned.
if (client->isInDirectClient()) {
return true;
}

ShardingState* shardingState = ShardingState::get(client->getServiceContext());
if (!shardingState->enabled()) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/s/strategy.cpp
Expand Up @@ -195,7 +195,7 @@ void Strategy::queryOp(OperationContext* txn, Request& r) {
uassertStatusOK(readPrefExtractStatus);
}

auto canonicalQuery = CanonicalQuery::canonicalize(q);
auto canonicalQuery = CanonicalQuery::canonicalize(q, WhereCallbackNoop());
uassertStatusOK(canonicalQuery.getStatus());

// Do the work to generate the first batch of results. This blocks waiting to get responses
Expand Down

0 comments on commit 2f7b99c

Please sign in to comment.