Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6075

Accessing array elements by position fails in $project

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.1.2
    • Fix Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Operating System:
      ALL

      Description

      Insert some data:
      db.foo.insert({title:"A doc", intervals:[

      {value:1, x:"a"}

      ,

      {value:2,x:"b"}

      ,

      {value:3,x:"c"}

      ]});

      Verify it's there:
      db.foo.find()
      { "_id" : ObjectId("4fd776800821eeb296a71a70"), "title" : "A doc", "intervals" : [

      {"value" : 1, "x" : "a"}

      ,

      {"value" : 2, "x" : "b"}

      ,

      {"value" : 3, "x" : "c"}

      ] }

      Try a projection:
      db.foo.aggregate({$project:{title:1, i1:"$intervals.0"}})
      {
      "errmsg" : "exception: assertion src/mongo/db/pipeline/value.cpp:446",
      "code" : 0,
      "ok" : 0
      }

      Try another:
      db.foo.aggregate({$project:{title:1, i1:"$intervals.0.value"}})
      {
      "errmsg" : "exception: assertion src/mongo/db/pipeline/value.cpp:446",
      "code" : 0,
      "ok" : 0
      }

        Issue Links

          Activity

          • Comments
          Hide
          ian.whalen Ian Whalen added a comment -

          Closing as dupe of SERVER-4589. Please comment if you believe there is something in your request not covered there.

          Show
          ian.whalen Ian Whalen added a comment - Closing as dupe of SERVER-4589 . Please comment if you believe there is something in your request not covered there.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: