-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.2.6, 2.5.3
-
ALL
-
Hi,
It looks like there was a behavior change between 2.0 and 2.2 that results in an error 13431 if you attempt to sort by a key that has been explicitly excluded in a projection when running a query via a mongos.
I was just wondering if this is expected behavior.
mongos> db.version() 2.0.9 mongos> db.foo.save({id:3, value:'c'}) mongos> db.foo.save({id:2, value:'b'}) mongos> db.foo.save({id:1, value:'a'}) mongos> db.foo.find({},{id:0}).sort({id:1}) { "_id" : ObjectId("523bd35dff9a7c468936efba"), "value" : "a" } { "_id" : ObjectId("523bd358ff9a7c468936efb9"), "value" : "b" } { "_id" : ObjectId("523bd352ff9a7c468936efb8"), "value" : "c" }
mongos> db.version() 2.2.6 mongos> db.foo.find({},{id:0}).sort({id:1}) error: { "$err" : "have to have sort key in projection and removing it", "code" : 13431 }
- is related to
-
SERVER-11877 mongos query results include sort fields implicitly excluded by projection
- Closed
- related to
-
SERVER-19355 Support skip, limit, and projection in new find/getMore commands path on mongos
- Closed