-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.6.1
-
Component/s: Aggregation Framework
-
None
-
ALL
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
In the mongodb document:
The example query:
db.orders.aggregate([
{
$lookup:
,
pipeline: [
{ $match:
{ $expr:
,
{ $gte: [ "$instock", "$$order_qty" ] }
]
}
}
},
{ $project:
}
],
as: "stockdata"
}
}
])
This runs fine, but if the line:
let: { order_item: "$item", order_qty: "$ordered" },
is replaced by:
let: { ORDER_ITEM: "$item", ORDER_QTY: "$ordered" },
and replace these variables in the other two lines:
{ $eq: [ "$stock_item", "$$ORDER_ITEM" ] }
,
{ $gte: [ "$instock", "$$ORDER_QTY" ] }
The mongo shell returns error:
assert: command failed:
{ "ok" : 0, "errmsg" : "'ORDER_ITEM' starts with an invalid character for a user variable name", "code" : 16867, "codeName" : "Location16867" }: aggregate failed
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:403:5
DB.prototype._runAggregate@src/mongo/shell/db.js:260:9
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1212:12
@(shell):1:1
2018-05-07T18:11:21.195-0400 E QUERY [thread1] Error: command failed:
{ "ok" : 0, "errmsg" : "'ORDER_ITEM' starts with an invalid character for a user variable name", "code" : 16867, "codeName" : "Location16867" }: aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:16:14
assert.commandWorked@src/mongo/shell/assert.js:403:5
DB.prototype._runAggregate@src/mongo/shell/db.js:260:9
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1212:12
@(shell):1:1