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
      }

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: