-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
None
-
3
-
TBD
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Consider where an empty sort spec is a valid use case and where it should be disallowed.
For example, here, empty sort specs are disallowed:
- SERVER-96579
db.nodata.aggregate([{$group: {_id: "$a", o: {$top: {output: 'a', sortBy: {}}}}}]); MongoServerError[Location9657900]: Value for 'sortBy' must be a non-empty object
rs0 [direct: primary] test> db.test.aggregate([{$match: {a: {$gte: 0}}}, {$sort: {}}]) MongoServerError[Location15976]: $sort stage must have at least one sort key
Whereas here, they are a valid query:
rs0 [direct: primary] test> db.test.find().sort({}) [ { _id: ObjectId('68790b382cd1e62966ffa76e'), a: 0, b: 0 }, ... ]
The inspection should be done on a case-by-case basis.
- is related to
-
SERVER-96579 Do not allow empty sortBy for $top/$topN/$bottom/$bottomN
-
- Closed
-