You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is very edge-case issue, but came across it today, as it's the first of the month.
Essentially, if a creating a new date using $dateFromParts, and inside that expression you also subtract a day, the result ends up being a year and a day before its input. This only happens for dates that are the first of the month (eg. '02/01/2022'). Other dates work as expected. This same behavior is not replicated in mongo playground.
I made a quick sample repo demonstrating the issue.
If you pass the script above { date: '02/01/2022' }, the result will be 01/31/2021 when it should be 01/31/2022. If you pass it 02/02/2022 it returns 02/01/2022.
We tested this in versions 6.0, 5.1, 5.0, and 4.4 and all got the same results.
The text was updated successfully, but these errors were encountered:
remainder is correctly updated from day->month but is not reset for the next unit transition month -> year. An else block after L68 that resets remainder should fix it since it must not carry over to the next unit when we don't take either of the above paths.
This is just from code analysis and has not been verified yet. Looking forward to your PR and thanks again for catching this.
This is very edge-case issue, but came across it today, as it's the first of the month.
Essentially, if a creating a new date using
$dateFromParts
, and inside that expression you also subtract a day, the result ends up being a year and a day before its input. This only happens for dates that are the first of the month (eg. '02/01/2022'). Other dates work as expected. This same behavior is not replicated in mongo playground.I made a quick sample repo demonstrating the issue.
Here's the Aggregator script as well:
If you pass the script above
{ date: '02/01/2022' }
, the result will be01/31/2021
when it should be01/31/2022
. If you pass it02/02/2022
it returns02/01/2022
.We tested this in versions 6.0, 5.1, 5.0, and 4.4 and all got the same results.
The text was updated successfully, but these errors were encountered: