[SERVER-22436] Allow parsing of string literals in aggregation's $project Created: 02/Feb/16  Updated: 06/Dec/22  Resolved: 24/Jun/16

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

Type: New Feature Priority: Major - P3
Reporter: Charlie Swanson Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: eng-s
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-18966 Allow exclusion in $project stage of ... Closed
Duplicate
duplicates SERVER-18966 Allow exclusion in $project stage of ... Closed
Assigned Teams:
Query
Backwards Compatibility: Fully Compatible
Participants:

 Description   

Currently a string literal as a value in a $project stage will cause an error:

db.foo.aggregate([{$project: {a: "hi"}}])
assert: command failed: {
	"errmsg" : "exception: FieldPath 'hi' doesn't start with $",
	"code" : 16873,
	"ok" : 0
} : aggregate failed
Error: command failed: {
	"errmsg" : "exception: FieldPath 'hi' doesn't start with $",
	"code" : 16873,
	"ok" : 0
} : aggregate failed
    at Error (<anonymous>)
    at doassert (src/mongo/shell/assert.js:11:14)
    at Function.assert.commandWorked (src/mongo/shell/assert.js:254:5)
    at DBCollection.aggregate (src/mongo/shell/collection.js:1278:12)
    at (shell):1:8
2016-02-02T12:12:03.131-0500 E QUERY    Error: command failed: {
	"errmsg" : "exception: FieldPath 'hi' doesn't start with $",
	"code" : 16873,
	"ok" : 0
} : aggregate failed
    at Error (<anonymous>)
    at doassert (src/mongo/shell/assert.js:11:14)
    at Function.assert.commandWorked (src/mongo/shell/assert.js:254:5)
    at DBCollection.aggregate (src/mongo/shell/collection.js:1278:12)
    at (shell):1:8 at src/mongo/shell/assert.js:13

We should allow this, with the semantics that it creates or replaces a field, and has that string literal as its value.



 Comments   
Comment by Charlie Swanson [ 24/Jun/16 ]

This was resolved with 752eb0f448987b3e4183beacc622f4e95e7803be

Comment by Asya Kamsky [ 05/Mar/16 ]

currently to include string literal the {$literal:"stringhere"} has to be used.

Generated at Thu Feb 08 04:00:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.