[CSHARP-4804] Slice projection must be rendered differently for Find and Aggregate Created: 01/Oct/23 Updated: 28/Oct/23 Resolved: 06/Oct/23 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.22.0 |
| Type: | Bug | Priority: | Blocker - P1 |
| Reporter: | Alex Gavrilov | Assignee: | Robert Stam |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Documentation Changes: | Not Needed | ||||||||
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
||||||||
| Description |
| Comments |
| Comment by Githook User [ 06/Oct/23 ] | |||||||
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | |||||||
| Comment by Githook User [ 06/Oct/23 ] | |||||||
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | |||||||
| Comment by Robert Stam [ 04/Oct/23 ] | |||||||
|
Regardless of whether the server ends up supporting both forms of $slice in $project, the driver needs to support existing versions of the server that already exist and have the current behavior. Looks like the solution on the driver side is to Render the slice projection differently depending on whether it is being used with Find or with Project. | |||||||
| Comment by Robert Stam [ 02/Oct/23 ] | |||||||
|
I've created a SERVER ticket asking why the projection form of $slice only works with Find and not with $project. | |||||||
| Comment by Robert Stam [ 02/Oct/23 ] | |||||||
|
There are two forms of the $slice operator. See also: https://www.mongodb.com/docs/manual/reference/operator/projection/slice/ But apparently this other form only works with Find, not with a $project stage. I am investigating possible fixes. Here's a small test using the MongoDB shell that illustrates that the projection form of $slice only works with Find:
| |||||||
| Comment by Alex Gavrilov [ 01/Oct/23 ] | |||||||
|
This is what I get as an output when I invoke .ToString() for a definition, which is built using BuildGetResultsPageDefinition method above
However, if manually one tunes the query to below it will execute fine:
According to mongo documentation $slice should accept the array of 3 elements, where first mandatory element is array | |||||||
| Comment by PM Bot [ 01/Oct/23 ] | |||||||
|
Hi eeasy.breezy@icloud.com, thank you for reporting this issue! The team will look into it and get back to you soon. |