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

    XMLWordPrintable

    Details

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

      Description

      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.

        Attachments

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

          Issue Links

            Activity

              People

              Assignee:
              tess.avitabile Tess Avitabile
              Reporter:
              jracabado João Acabado
              Participants:
              Votes:
              5 Vote for this issue
              Watchers:
              23 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: