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

mongos query results include sort fields implicitly excluded by projection

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.4
    • Component/s: Querying, Sharding
    • Labels:
      None
    • ALL

      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 }
      

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

              Created:
              Updated:
              Resolved: