Repository navigation
Write $merge's keepExisting as the server spells it - #4591
Open
evanchooly wants to merge 1 commit into
Open
evanchooly wants to merge 1 commit into
evanchooly wants to merge 1 commit into
Conversation
MergeCodec lower-cased the driver's enum names, so WhenMatched.KEEP_EXISTING became "keep_existing", which the server rejects. Write the camel-case MQL value instead.
This was referenced Nov 24, 2026
Member
Author
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.
Problem
MergeCodecwriteswhenMatchedandwhenNotMatchedas the driver enum's name, lower-cased. That works for the one-word values (replace,merge,fail,insert,discard). ButWhenMatched.KEEP_EXISTINGbecomes"keep_existing", and the server rejects the stage:So
$mergewithwhenMatched: "keepExisting"can't be expressed in Morphia at all. The bug is on 2.5.x as well.I found it while binding
$mergefor the operator-audit case generator (#4592), which converts MQL values likekeepExistingto driver constants.Fix
The codec writes the camel-case MQL value:
KEEP_EXISTING→keepExisting. One-word values are unchanged. It lower-cases withLocale.ROOT, so the output no longer depends on the default locale.TestMerge#keepExistingruns the stage against the server and checks that the matched document is kept and the unmatched one inserted. Without the fix it fails with theBadValueabove.TestMergepasses under Critter and reflection.For review
WhenMatched.PIPELINEstill writes"pipeline", which isn't a server value. A pipeline is set withwhenMatched(Stage...), which writes the stages instead, so I left it alone.Self-reviewed only.