-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
Query
-
ALL
-
-
None
-
0
-
None
-
None
-
None
-
None
-
None
-
None
The server accepts a query with a projection that specifies both _id and a subfield of _id, such as {_id: 0, "_id.x": 1}. The results of such a query will change depending on whether there is an index available for the subfield of _id.
For context, the aggregation system disallows such a projection:
> db.foo.aggregate([{$project: {_id: 0, "_id.x": 1}}]) assert: command failed: { "ok" : 0, "errmsg" : "Invalid $project specification: specification contains two conflicting paths. Cannot specify both '_id.x' and '_id': { _id: 0.0, _id.x: 1.0 }", "code" : 40176, "codeName" : "Location40176" } : aggregate failed _getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:16:14 assert.commandWorked@src/mongo/shell/assert.js:403:5 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1332:5 @(shell):1:1
- duplicates
-
SERVER-7502 Query's projection does not obey partial inclusion or exclusion of _id
-
- Closed
-