[SERVER-66969] The $add aggregation expression is not always commutative Created: 02/Jun/22  Updated: 06/Dec/22  Resolved: 09/Jun/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 6.0.0-rc8
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: James Wahlin Assignee: Backlog - Query Optimization
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
duplicates SERVER-63099 Constant folding should not assume ar... Closed
Assigned Teams:
Query Optimization
Operating System: ALL
Steps To Reproduce:

db.test.drop();

db.test.insert({_id: 1, x: new Date()});

// Returns a result.
db.test.aggregate([{$project: {a: {$add: [null, new Date(), "$x"]}}}])

// Fails with error code 16612, "only one date allowed in an $add expression".
db.test.aggregate([{$project: {a: {$add: [new Date(), "$x", null]}}}])

Participants:
Linked BF Score: 53

 Description   

The $add expression is defined as being commutative, which is not true when a null value exists in the list being summed.



 Comments   
Comment by Davis Haupt (Inactive) [ 09/Jun/22 ]

This can probably be closed as a duplicate of SERVER-63099

Generated at Thu Feb 08 06:06:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.