Core Server
  1. Core Server
  2. SERVER-5991

$project does not allow creation of a new field with literal value

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major - P3 Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.1.1
    • Fix Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Backport:
      No
    • Operating System:
      ALL
    • Bug Type:
      Unknown
    • # Replies:
      2
    • Last comment by Customer:
      false

      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

        Issue Links

          Activity

          Hide
          Asya Kamsky
          added a comment -

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

          Show
          Asya Kamsky
          added a comment - looks like the current implementation of $literal resolves this case.
          Hide
          Mathias Stearn
          added a comment -

          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.

          Show
          Mathias Stearn
          added a comment - 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.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                1 year, 39 weeks, 4 days ago
                Date of 1st Reply: