-
Type: Bug
-
Resolution: Incomplete
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Environment:OS: linux
node.js / npm versions:
Additional info:
-
Developer Tools
-
Not Needed
Problem Statement/Rationale
$let aggregation stage when used with $avg (Array) produces incorrect result
Please be sure to attach relevant logs with any sensitive data redacted.
How to retrieve logs for: Compass; Shell
Steps to Reproduce
db.products.insertMany([
{
_id: 1,
name: "UltraHD TV 55''",
price: 1200.00,
rating: [5, 4, 5, 3, 4],
stocks:
},
{
_id: 2,
name: "Smartwatch 4",
price: 299.99,
rating: [4, 5, 4, 4, 5],
stocks:
},
{
_id: 3,
name: "Wireless Earbuds",
price: 129.99,
rating: [4, 3, 4, 5, 4],
stocks:
},
{
_id: 4,
name: "Gaming Laptop",
price: 1500.00,
rating: [5, 5, 5, 4, 5],
stocks:
},
{
_id: 5,
name: "Tablet 8''",
price: 450.00,
rating: [4, 4, 3, 4, 4],
stocks:
}
]);
db.products.aggregate([
{
'$project': {
name: 1,
updateNeeded: {
'$let': {
vars: {
avgRating:
},
in:
}
}
}
},
{
'$sort':
}
])
Output -
[
,
,
,
,
]
Expected Results
All documents must have updateNeeded as 'false'
Actual Results
updateNeeded is 'true' for all documents
Additional Notes
Any additional information that may be useful to include.