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

$all with nested array behaves differently in 2.4 v 2.5

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.3, 2.5.4
    • Component/s: Querying
    • Labels:
    • Environment:
    • ALL
    • Hide

      2.5.5-pre-

      > db.c.insert({a:["red","blue"]})
      > db.c.insert({a:["red"]})
      > db.c.count({a:{$all:[["red"]]}})
      { "_id" : ObjectId("528c0a6e1d37e39f262901af"), "a" : [  "red" ] }
      > db.c.count({a:{$all:["red"]}})
      { "_id" : ObjectId("528c0a661d37e39f262901ae"), "a" : [  "red",  "blue" ] }
      { "_id" : ObjectId("528c0a6e1d37e39f262901af"), "a" : [  "red" ] }
      

      2.4.9-pre-

      > db.c.insert({a:["red","blue"]})
      > db.c.insert({a:["red"]})
      > db.c.find({a:{$all:[["red"]]}})
      > db.c.find({a:{$all:["red"]}})
      { "_id" : ObjectId("528c0a3b679ed5d9487c0be4"), "a" : [  "red",  "blue" ] }
      { "_id" : ObjectId("528c0a44679ed5d9487c0be5"), "a" : [  "red" ] }
      
      Show
      2.5.5-pre- > db.c.insert({a:[ "red" , "blue" ]}) > db.c.insert({a:[ "red" ]}) > db.c.count({a:{$all:[[ "red" ]]}}) { "_id" : ObjectId( "528c0a6e1d37e39f262901af" ), "a" : [ "red" ] } > db.c.count({a:{$all:[ "red" ]}}) { "_id" : ObjectId( "528c0a661d37e39f262901ae" ), "a" : [ "red" , "blue" ] } { "_id" : ObjectId( "528c0a6e1d37e39f262901af" ), "a" : [ "red" ] } 2.4.9-pre- > db.c.insert({a:[ "red" , "blue" ]}) > db.c.insert({a:[ "red" ]}) > db.c.find({a:{$all:[[ "red" ]]}}) > db.c.find({a:{$all:[ "red" ]}}) { "_id" : ObjectId( "528c0a3b679ed5d9487c0be4" ), "a" : [ "red" , "blue" ] } { "_id" : ObjectId( "528c0a44679ed5d9487c0be5" ), "a" : [ "red" ] }

      The $all query operator can return different results in 2.4 v 2.5 versions of mongodb when given a nested array as an argument. Not sure which behavior is "correct" here, but want to confirm that this change is intentional and that this change gets documented somewhere (and this may become a DOCS ticket).

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            luke.lovett Luke Lovett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: