[SERVER-34879] $let in the $lookup pipeline only allows variable names with lower cases Created: 07/May/18 Updated: 27/Oct/23 Resolved: 08/May/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 3.6.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Jun Liu | Assignee: | Andy Schwerin |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
In the mongodb document:
The example query: db.orders.aggregate([ , , }
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" ] } , 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
|
| Comments |
| Comment by Andy Schwerin [ 08/May/18 ] |
|
Per the documentation on user variables in aggregation pipelines, user defined variables must start with a lower case letters a-z or with non-ascii characters. |