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

Positional projection queries (and positional update ops) should fail with error if multiple arrays encountered

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Query 10 (02/22/16)

      Running the following commands on 2.6 and 2.4 gives different output when running following commands:

      db.createCollection("PositionalOperatorRepro")
      db.PositionalOperatorRepro.insert({"_id": "test1",  "Items": [ { "Id": 1 }, { "Id": 2 }  ] })
      db.PositionalOperatorRepro.find({ "_id" : "test1", "Items" : { "$exists" : true, "$elemMatch" : { "Id" : 2 } } } , { "Items.$" : 1 })
      
      // 2.4 returns
      {.. Items: [{Id:2}]}
      // 2.6 returns
      {.. Items: [{Id:1}]}
      // 2.6 without $exists
      {.. Items: [{Id:2}]}
      

      If we remove the "$exists" : true criteria the output will be the same.

      Is this change documented anywhere? There could be compatibility issues when upgrading.

      I'm attaching a screen shot where I reproduced this behavior.

        1. match_expr.png
          match_expr.png
          64 kB
        2. repro.png
          repro.png
          39 kB

            Assignee:
            tess.avitabile@mongodb.com Tess Avitabile (Inactive)
            Reporter:
            jracabado João Acabado
            Votes:
            5 Vote for this issue
            Watchers:
            23 Start watching this issue

              Created:
              Updated:
              Resolved: