...
$group with $$ROOT starting failing recently when running the C# driver tests. Not sure when exactly it started failing, but it can be reproduced using 4.1.3-231-ga106c80c19. Here's a repro showing it working in 4.0.2: > db.version() 4.0.2 > db.test.find() { "_id" : 1, "x" : 1 } { "_id" : 2, "x" : 2 } > db.test.aggregate([ { $group : { _id : "$$ROOT" } } ]) { "_id" : { "_id" : 2, "x" : 2 } } { "_id" : { "_id" : 1, "x" : 1 } } >
xgen-internal-githook commented on Tue, 9 Oct 2018 19:57:53 +0000: Author: {'name': 'Ian Boros', 'email': 'ian.boros@10gen.com'} Message: SERVER-37459 special case for $group with $$ROOT or $$CURRENT Branch: master https://github.com/mongodb/mongo/commit/627d6027b15b2355cb9621dd28cce4b7024fbf9c david.storch commented on Wed, 3 Oct 2018 18:52:58 +0000: Thanks rstam! I believe this is a regression due to the changes for SERVER-9507. I'm assigning to justin.seyster to implement a fix. rstam commented on Wed, 3 Oct 2018 18:35:43 +0000: I realize that this particular use of $group is a bit odd since all the documents (and therefore $$ROOT) will already be unique by virtue of the _id being unique. This query was generated by the C# driver as part of a LINQ test. Even if it seems a bit odd, it still should work (as it did in 4.0.2).
Repro using 4.1.3-231-ga106c80c19: > db.version() 4.1.3-231-ga106c80c19 > db.test.find() { "_id" : 1, "x" : 1 } { "_id" : 2, "x" : 2 } > db.test.aggregate([ { $group : { _id : "$$ROOT" } } ]) 2018-10-03T14:24:20.951-0400 E QUERY [js] Error: command failed: { "ok" : 0, "errmsg" : "FieldPath::tail() called on single element path", "code" : 16409, "codeName" : "Location16409" } : aggregate failed : _getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:18:14 _assertCommandWorked@src/mongo/shell/assert.js:534:17 assert.commandWorked@src/mongo/shell/assert.js:618:16 DB.prototype._runAggregate@src/mongo/shell/db.js:260:9 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1056:12 @(shell):1:1 >