Repository navigation
Write small whole-number parameters as Int32 - #4552
Open
evanchooly wants to merge 1 commit into
Open
evanchooly wants to merge 1 commit into
evanchooly wants to merge 1 commit into
Conversation
Sort directions were written with writeInt64 although they are ints, and skip, limit, sample size, date amounts, shift offsets, binSize and mod operands always went out as Int64. They are now Int32 when they fit, as the documentation and the shell write them. 48 documented examples that failed only on this now convert to the case runner.
This was referenced Nov 22, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #4551.
Problem
Morphia wrote several whole-number parameters as 64-bit integers where the MongoDB documentation and the shell use 32-bit ones. For example,
$setWindowFields: {sortBy: {orderDate: 1}}went out as{orderDate: NumberLong(1)}, even thoughSort.getOrder()is anintand the codec simply calledwriteInt64. The server treats the two alike, so results never differed. But the operator audits' strict serialization check caught the difference in 49 documented examples (#4548, #4549, #4550, #4551), which kept them on the legacy path. The legacy comparator ignored number types.Changes
$setWindowFields,$fill,$top/$bottom/$topN/$bottomNand$sortArray, which all usedwriteInt64for anint.longparameters are written as Int32 when they fit. The newCodecHelper.wholewrites Int32 when the value fits and Int64 otherwise. It covers$skip,$limit,$sample'ssize,$dateAdd/$dateSubtract'samount,$shift'sby,$dateTrunc'sbinSizeand the integral operands ofFilters.mod. The public API still takeslong, so no signatures change.$isoWeekYear, is the server returning a Long, not an encoding issue, so it stays legacy-only. Form report: 10 overrides. Ledger: 341 cases. Legacy-only: 33.Decision for review