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

Can't perform queries on sub-documents stored in a field name = the value of that document's index within an array in version 2.4

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.4.9
    • Fix Version/s: 2.5.4
    • Component/s: Querying
    • Labels:
    • Environment:
    • Backwards Compatibility:
      Minor Change
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      2.4.9-pre-

      > db.c.insert({a:[{"0":{b:"Hello"}}]})
      > db.c.find({"a.0.b":"Hello"})
      >

      Compare that to 2.5.5-pre-:

      > db.c.insert({a:[{"0":{b:"Hello"}}]})
      Insert WriteResult({ "ok" : 1, "n" : 1 })
      > db.c.find({"a.0.b":"Hello"})
      { "_id" : ObjectId("52a10cd0dd47ad0373e22ae6"), "a" : [ { "0" : { "b" : "Hello" } } ] }
      >

      Show
      2.4.9-pre- > db.c.insert({a:[{"0":{b:"Hello"}}]}) > db.c.find({"a.0.b":"Hello"}) > Compare that to 2.5.5-pre-: > db.c.insert({a:[{"0":{b:"Hello"}}]}) Insert WriteResult({ "ok" : 1, "n" : 1 }) > db.c.find({"a.0.b":"Hello"}) { "_id" : ObjectId("52a10cd0dd47ad0373e22ae6"), "a" : [ { "0" : { "b" : "Hello" } } ] } >

      Description

      Versions 2.4 and 2.5 of MongoDB return different results when performing a query on a sub-document stored in a field that has a numeric name that happens to be the value of the index at which that document is stored within an array field.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: