[SERVER-6187] incorrect uassert message on attempt to subtract a date from a number Created: 23/Jun/12  Updated: 15/Aug/12  Resolved: 29/Jun/12

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Aaron Staple Assignee: Matt Dannenberg
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-6240 Disable math with Dates in agg Closed
Operating System: ALL
Participants:

 Description   

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() ] } } } ) );



 Comments   
Comment by Mathias Stearn [ 29/Jun/12 ]

Superseded by SERVER-6240

Generated at Thu Feb 08 03:10:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.