-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 7.0.0, 8.0.0, 8.3.0, 9.0.0
-
Component/s: None
-
None
-
Query Optimization
-
ALL
-
-
None
-
None
-
None
-
None
-
None
-
None
-
None
On a dotted sort path through an array, adding a projection of that path changes the order of the sort result. With a: [{y: 5}, "s"] in document 1 and a: [{y: 3}] in document 2, find().sort({"a.y": 1}) returns [1, 2], but find({},
{"a.y": 1}).sort(
{"a.y": 1}) returns [2, 1]. In aggregation, [$limit, $sort, $project {_id: 1}] flips the order in the same way, while [$limit, $sort] does not.
Found with Ephyra, a property-based testing tool I'm developing; this report was drafted with an LLM from the test output, and I reviewed it and reran the repro on 9.0.8 and master.
- related to
-
SERVER-54768 Sort/project re-ordering is inconsistent between find() and aggregation
-
- Backlog
-