[SERVER-43068] $meta 'sortKey' projection doesn't contain all fields sorted on Created: 28/Aug/19 Updated: 27/Oct/23 Resolved: 28/Aug/19 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Raiden Worley (Inactive) | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Query
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: | Create a database where there are multiple fields:
Create a sort command containing the "$meta" : "sortKey" projection:
Now the fields in the returned documents are sorted as asked in the query, but the 'sortKey' field only has some of the information used to sort:
Now the sort is occurring on both 'a' and 'b' but only the values of 'a' are included in the sortKey field. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Participants: |
| Comments |
| Comment by Raiden Worley (Inactive) [ 28/Aug/19 ] |
|
bernard.gorman Yeah that perfectly addresses it! Thanks to both of you for taking the time to look at this, I learned a lot. |
| Comment by Bernard Gorman [ 28/Aug/19 ] |
|
max.hirschhorn: yes, that's the conclusion we came to after discussing this ticket in the query channel. I didn't know we'd added a bsonObjToArray helper, very cool! carl.worley, does this address your use-case? If so, I'll close the ticket. |
| Comment by Max Hirschhorn [ 28/Aug/19 ] |
|
The output included in the description is just the behavior of how the mongo shell deals with BSON containing duplicate field names. The bsonObjToArray() function introduced in |