[SERVER-5991] $project does not allow creation of a new field with literal value Created: 01/Jun/12  Updated: 15/Feb/13  Resolved: 27/Aug/12

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

Type: Bug Priority: Major - P3
Reporter: Asya Kamsky Assignee: Mathias Stearn
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-5782 need a $literal operator to help prev... Closed
Operating System: ALL
Participants:

 Description   

$project allows insertion of new computed fields, however it doesn't seem to allow insertion of new literal fields.

{$project : {"newfield":"abc"}}
gives "errmsg" : "exception: field path references must be prefixed with a '$' (\"abc\""

It would be nice to not have to hack around it via:
{$project : {"newfield": {$add: ["abc",""]}}}

Possibly related to https://jira.mongodb.org/browse/SERVER-5762 and https://jira.mongodb.org/browse/SERVER-5782



 Comments   
Comment by Mathias Stearn [ 16/Jul/12 ]

Actually the current implemention of $literal is slated for removal because it is known to be broken. I think there is a 5-min replacement, but if it takes longer there will be no $literal in 2.2.

Comment by Asya Kamsky [ 14/Jul/12 ]

looks like the current implementation of $literal resolves this case.

Generated at Thu Feb 08 03:10:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.