-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.4.0-rc2
-
Component/s: Aggregation Framework
-
None
-
ALL
Normally you're allowed to "chain" or group together multiple operations in a single $project. This does not seem to work with dates and addition - even though result is a date it cannot be used in the same $project stage, but the next one:
spr@local(2.4.0-rc2) > db.testD.findOne()
{
"_id" : ObjectId("513b2a362d8edd2720469b86"),
"idate" : ISODate("2013-03-09T12:25:26.370Z")
}
spr@local(2.4.0-rc2) > db.testD.aggregate({$project:{ndate:{$add:["$idate",19800000]}}})
{
"result" : [
],
"ok" : 1
}
spr@local(2.4.0-rc2) > db.testD.aggregate({$project:{ndate:{$add:["$idate",19800000]}}},{$project:{y:{$year:"$ndate"}}})
{
"result" : [
],
"ok" : 1
}
// BUT
spr@local(2.4.0-rc2) > db.testD.aggregate({$project:{nyear:{$year:{$add:["$idate",19800000]}}}})
Error: Printing Stack Trace
at printStackTrace (src/mongo/shell/utils.js:37:7)
at DBCollection.aggregate (src/mongo/shell/collection.js:897:1)
at (shell):1:10
Sat Mar 9 12:38:17.001 JavaScript execution failed: aggregate failed: {
"errmsg" : "exception: the $year operator does not accept an object as an operand",
"code" : 16021,
"ok" : 0
} at src/mongo/shell/collection.js:L898
- duplicates
-
SERVER-9289 Date operators incorrectly throw exceptions for object arguments
- Closed