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

Invalid "cannot use part of (results of results.answers) to traverse elemt

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Works as Designed
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Querying
    • None
    • Query
    • ALL
    • Hide

      > db.survey.find()
      {
        "_id": 1,
        "results": [
          {
            "item": "A",
            "score": 5,
            "answers": [
              "a1",
              "a2",
              "a3"
            ]
          },
          {
            "item": "B",
            "score": 8,
            "answers": [
              "a2",
              "a3",
              "a4"
            ]
          }
        ]
      }
      {
        "_id": 2,
        "results": [
          {
            "item": "C",
            "score": 8,
            "answers": [
              "a1",
              "a2"
            ]
          },
          {
            "item": "B",
            "score": 4,
            "answers": [
              "a1",
              "a2"
            ]
          }
        ]
      }
       
      > db.survey.update( {}, { $pullAll : {"results.answers": ["a3", "a4"]}}, { multi : true})
      cannot use the part (results of results.answers) to traverse the element ({results: [ { item: "A", score: 5.0, answers: [ "a1", "a2", "a3" ] }, { item: "B", score: 8.0, answers: [ "a2", "a3", "a4" ] } ]})
      WriteResult({
        "nMatched": 0,
        "nUpserted": 0,
        "nModified": 0,
        "writeError": {
          "code": 16837,
          "errmsg": "cannot use the part (results of results.answers) to traverse the element ({results: [ { item: \"A\", score: 5.0, answers: [ \"a1\", \"a2\", \"a3\" ] }, { item: \"B\", score: 8.0, answers: [ \"a2\", \"a3\", \"a4\" ] } ]})"
        }
      })
      

      Show
      > db.survey.find() { "_id": 1, "results": [ { "item": "A", "score": 5, "answers": [ "a1", "a2", "a3" ] }, { "item": "B", "score": 8, "answers": [ "a2", "a3", "a4" ] } ] } { "_id": 2, "results": [ { "item": "C", "score": 8, "answers": [ "a1", "a2" ] }, { "item": "B", "score": 4, "answers": [ "a1", "a2" ] } ] }   > db.survey.update( {}, { $pullAll : {"results.answers": ["a3", "a4"]}}, { multi : true}) cannot use the part (results of results.answers) to traverse the element ({results: [ { item: "A", score: 5.0, answers: [ "a1", "a2", "a3" ] }, { item: "B", score: 8.0, answers: [ "a2", "a3", "a4" ] } ]}) WriteResult({ "nMatched": 0, "nUpserted": 0, "nModified": 0, "writeError": { "code": 16837, "errmsg": "cannot use the part (results of results.answers) to traverse the element ({results: [ { item: \"A\", score: 5.0, answers: [ \"a1\", \"a2\", \"a3\" ] }, { item: \"B\", score: 8.0, answers: [ \"a2\", \"a3\", \"a4\" ] } ]})" } })

    Description

      Similar to SERVER-20171, except that client is trying to remove elements from arrays of arrays. There are only two documents in the collection

      Attachments

        Activity

          People

            backlog-server-query Backlog - Query Team (Inactive)
            lorne.schachter Lorne Schachter
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: