[GODRIVER-1904] Wrong sort sometimes when based on two fields Created: 02/Mar/21 Updated: 27/Oct/23 Resolved: 08/Mar/21 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | API |
| Affects Version/s: | 1.4.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Allen Gao | Assignee: | Unassigned |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
I write a sample test on: https://github.com/GaoJianAllen/MongoTest When use sort method to sort fields, it will return wrong sort result sometime. Key code:
Expect:
Actual(Sometimes):
Command is always correct.
|
| Comments |
| Comment by Allen Gao [ 05/Mar/21 ] | |
|
Hi Kevin, It resovled my problem. Thanks! | |
| Comment by Kevin Albertson [ 04/Mar/21 ] | |
|
Hi jian.gao1@hp.com, thank you for the report! I believe this is due to using a bson.M as the sort document, which does not guarantee order of fields in the BSON document. You can alternatively use a bson.D to retain the key order.
The changes of |