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

$exists behaves differently when matching an array element

    XMLWordPrintable

    Details

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

      Description

      Problem:
      $exists appears to match arrays in a dotted expression differently between versions.

      Reproduce:

      db.q.drop()
      db.q.insert({ "a" : [ { "0" : { "2" : { "b" : "To the man who only has a hammer, everything he encounters begins to look like a nail." } } } ] })
      db.q.insert({ "a" : [ { "0" : { "2" : { "b" : 99 } } } ] })
      db.q.insert({ "a" : [ { "0" : { "2" : 42 } } ] })
      db.q.insert({ "a" : { "0" : { "x" : 42 } } })
      db.q.find( { "a.0.2" : { $exists : 0 } } )

      2.4.5 returns

      { "_id" : ObjectId("527068948a43120c67c8c621"), "a" : [ 	{ 	"0" : { 	"2" : { 	"b" : "To the man who only has a hammer, everything he encounters begins to look like a nail." } } } ] }
      { "_id" : ObjectId("527068948a43120c67c8c622"), "a" : [  {  "0" : {  "2" : {  "b" : 99 } } } ] }
      { "_id" : ObjectId("527068948a43120c67c8c623"), "a" : [  {  "0" : {  "2" : 42 } } ] }
      { "_id" : ObjectId("527068948a43120c67c8c624"), "a" : { "0" : { "x" : 42 } } }

      2.5.4-Pre returns

      { "_id" : ObjectId("527068b76ca3a8357d0fe436"), "a" : { "0" : { "x" : 42 } } }

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: