Details
-
Bug
-
Resolution: Fixed
-
Critical - P2
-
4.1.8
-
None
-
Fully Compatible
-
ALL
-
-
Query 2019-03-25, Query 2019-04-08
Description
Looks like DISTINCT_SCAN added in SERVER-9507 doesn't request the full document like it does correctly individual fields.
// correct
|
db.newTest.aggregate([
|
{$sort:{valueDate:1}},
|
{$group:{_id: "$valueDate", first: {$first: "$farmId"}}}
|
])
|
{ "_id" : ISODate("2019-01-01T00:00:00Z"), "first" : 3 }
|
{ "_id" : ISODate("2019-02-01T00:00:00Z"), "first" : 1 }
|
//incorrect
|
db.newTest.aggregate([
|
{$sort:{valueDate:1}},
|
{$group:{_id: "$valueDate", first: {$first: "$$ROOT"}}}
|
])
|
{ "_id" : ISODate("2019-01-01T00:00:00Z"), "first" : { "valueDate" : ISODate("2019-01-01T00:00:00Z") } }
|
{ "_id" : ISODate("2019-02-01T00:00:00Z"), "first" : { "valueDate" : ISODate("2019-02-01T00:00:00Z") } }
|
|