-
Type: Bug
-
Resolution: Won't Fix
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
ALL
Observed behavior: Attempt to subtract a date from a number triggers a uassert with the message "cannot subtract one date from another". Subtracting one date from another, meanwhile, seems to be allowed.
Expected behavior: The assertion message should be consistent with the operation that is not allowed.
It would also make sense to validate all date related subtraction cases to make sure the desired behavior is implemented / checked with assertions.
Test:
c = db.c; c.drop(); c.save( {} ); // Does not assert. printjson( c.aggregate( { $project:{ a:{ $subtract:[ new Date(), new Date() ] } } } ) ); // Asserts claiming that one date cannot be subtracted from another. printjson( c.aggregate( { $project:{ a:{ $subtract:[ 1, new Date() ] } } } ) );
- is duplicated by
-
SERVER-6240 Disable math with Dates in agg
- Closed