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

mongos query results include sort fields implicitly excluded by projection

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 2.5.4
    • Querying, Sharding
    • None
    • ALL

    Description

      When mongos is asked to perform on a sort on a field that is implicitly projected out (e.g. by an inclusion of another field), mongos does not strip out the field as expected.

      Reproduce with the following ("collection" can be either sharded or unsharded):

      mongos> db.collection.insert({_id:9, a:"hello"})
      mongos> db.collection.find({},{_id:1})
      { "_id" : 9 }
      mongos> db.collection.find({},{_id:1}).sort({a:1})
      { "_id" : 9, "a" : "hello" }
      

      It is not expected that "a" is returned in the results for the sorted query above. Running the same query when connected directly to the shard returns the correct results:

      > db.collection.find({},{_id:1})
      { "_id" : 9 }
      > db.collection.find({},{_id:1}).sort({a:1})
      { "_id" : 9 }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: