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

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

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: 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\ " ] } ]})" } })

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

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

              Created:
              Updated:
              Resolved: