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

$ projection operator doesn't validate corresponding field in query specifier in 2.5

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.5.4
    • 2.5.5
    • Querying
    • Fully Compatible
    • ALL
    • Hide

      2.4.9-pre-

      > db.g.insert({arr:[5]})
      > db.g.find({arr:{$gt:4}},{"arr.$":1})
      { "_id" : ObjectId("52a1164abed6d595b15ec697"), "arr" : [  5 ] }
      > db.g.find({arr:{$size:1}},{"arr.$":1})
      error: {
      	"$err" : "positional operator (arr.$) requires corresponding field in query specifier",
      	"code" : 16352
      }

      2.5.5-pre-

      > db.g.insert({arr:[5]})
      Insert WriteResult({ "ok" : 1, "n" : 1 })
      > db.g.find({arr:{$gt:4}},{"arr.$":1})
      { "_id" : ObjectId("52a1164add47ad0373e22ae8"), "arr" : [ 5 ] }
      > db.g.find({arr:{$size:1}},{"arr.$":1})
      { "_id" : ObjectId("52a1164add47ad0373e22ae8") }

      Show
      2.4.9-pre- > db.g.insert({arr:[5]}) > db.g.find({arr:{$gt:4}},{"arr.$":1}) { "_id" : ObjectId("52a1164abed6d595b15ec697"), "arr" : [ 5 ] } > db.g.find({arr:{$size:1}},{"arr.$":1}) error: { "$err" : "positional operator (arr.$) requires corresponding field in query specifier", "code" : 16352 } 2.5.5-pre- > db.g.insert({arr:[5]}) Insert WriteResult({ "ok" : 1, "n" : 1 }) > db.g.find({arr:{$gt:4}},{"arr.$":1}) { "_id" : ObjectId("52a1164add47ad0373e22ae8"), "arr" : [ 5 ] } > db.g.find({arr:{$size:1}},{"arr.$":1}) { "_id" : ObjectId("52a1164add47ad0373e22ae8") }

    Description

      Version 2.5 of MongoDB doesn't seem to look to see if there's a corresponding field to match with the $ projection operator. Consequently, malformed projections involving the $ operator return documents in version 2.5, but an error is thrown in 2.4.

      Attachments

        Issue Links

          Activity

            People

              benety.goh@mongodb.com Benety Goh
              luke.lovett Luke Lovett
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: