[CSHARP-2670] Sorting on DateTimeOffset field fails when default (Array) serialization is used Created: 24/Jul/19 Updated: 27/Oct/23 Resolved: 24/Sep/19 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Serialization |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Michał Gajek | Assignee: | Robert Stam |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
When sorting on DateTimeOffset field (ascending), the sort fails when default serialization (Array) is used.
Please find the tests attached below
|
| Comments |
| Comment by Robert Stam [ 24/Sep/19 ] | |||||||||||
|
The server documents how it implements sort order here: https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#bson-types-comparison-order Note the section on arrays, where it states: > With arrays, a less-than comparison or an ascending sort compares the smallest element of arrays, and a greater-than comparison or a descending sort compares the largest element of the arrays. In the sample data in this test the smallest element of the arrays is always 180. | |||||||||||
| Comment by Robert Stam [ 24/Sep/19 ] | |||||||||||
|
Closing as Works as Designed since this seems to be server related and not a driver issue. | |||||||||||
| Comment by Robert Stam [ 24/Sep/19 ] | |||||||||||
|
This appears to be related to the fact that the server is not sorting as expected when sorting on an array field. The collection contents during this test are:
The LINQ query you are using translates (in part) to the following aggregation framework pipeline:
Note that the server has NOT sorted the documents as you might have expected. The bottom line is that I don't think we can successfully sort `DateTimeOffset` data when the representation on the server is an array.
|