Inconsistent treatment of numerical path components between query and update

XMLWordPrintableJSON

    • Query Optimization
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In the query language, when a numerical path component is used to select an element of an array, elements are only selected if the numerical path component matches their exact fieldname:

      > db.c.insert({_id: 0, a: [0]})
      WriteResult({ "nInserted" : 1 })
      > db.c.find({"a.00": 0})
      > db.c.find({"a.0": 0})
      { "_id" : 0, "a" : [ 0 ] }
      

      In the update language, a numerical path components is parsed as an unsigned base 10 integer n, and we select the nth array element:

      > db.c.insert({_id: 0, a: [0]})
      WriteResult({ "nInserted" : 1 })
      > db.c.update({_id: 0}, {$set: {"a.00": 1}})
      WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
      > db.c.find()
      { "_id" : 0, "a" : [ 1 ] }
      

              Assignee:
              [DO NOT USE] Backlog - Query Optimization
              Reporter:
              Tess Avitabile (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated: