|
mongos returns an empty cursor with this aggregation when the db does not exist.
db.aggregate([{$match: {size: "medium"}}, {$documents: [{_id: 1, size: "medium"}, {_id: 2}]}]);
|
This command should return an error since $documents can only be used in the first stage in a pipeline.
Additionally, mongos will return an empty cursor with this aggregation. This aggregation should also raise an error since $unionWith must be used with a collection.
db.aggregate([
|
{
|
$unionWith: {
|
pipeline: [{ $documents: {$map: {input: {$range: [0, 5]}, in : {x: "$$this"}}}}]
|
}
|
},
|
{ $group: {_id: "$x", x: {$first: "$x"}}},
|
{ $project: {_id: 0}},
|
])
|
.toArray();
|
Discovered in SERVER-63811. The empty cursor is being returned by this logic:
if (executionNsRoutingInfoStatus.isOK()) {
|
cm = std::move(executionNsRoutingInfoStatus.getValue());
|
} else if (!(hasChangeStream &&
|
executionNsRoutingInfoStatus == ErrorCodes::NamespaceNotFound)) {
|
appendEmptyResultSetWithStatus(
|
opCtx, namespaces.requestedNss, executionNsRoutingInfoStatus.getStatus(), result);
|
return Status::OK();
|
}
|
However validation checks should have occurred before this logic and returned an error.
|