Repository navigation
Generate cases for $merge, $out and $unwind's options - #4592
Open
evanchooly wants to merge 1 commit into
Open
evanchooly wants to merge 1 commit into
evanchooly wants to merge 1 commit into
Conversation
Bind $merge and $out as named stages with a shorthand for their one-argument spelling, and $unwind as a named stage so its options generate. Options whose last parameter is an array spread an array's items, and enum values convert camel case to the driver's constants. Stages naming another database, and spellings Morphia writes otherwise, are gaps.
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 #4590.
Problems
1.
$mergeand$outexamples never generated. The generator had no binding for either stage, so every example ending in one was anUNBOUNDgap (stage $merge has no binding). The read pairing from #4589 (a find after a write joins the write's scenario) had nothing to attach to.2.
$unwind's options couldn't generate.$unwindwas bound positionally, so{ $unwind: { path: "$genres", includeArrayIndex: "genreIndex" } }was a gap:a document literal has no binding.3. Some MQL enum values could never compile. The generator upper-cased an enum value, so
whenMatched: "keepExisting"becameWhenMatched.KEEPEXISTING, notKEEP_EXISTING.Changes
dsl-bindings.jsongainsshorthand. ANAMEDoperator of one argument also takes that argument alone, so{$out: "coll"},{$merge: "coll"}and{$unwind: "$x"}emitout("coll"),merge("coll")andunwind("$x").DslBindings.verifyrejectsshorthandon anything but a one-argument named binding.$merge'son: ["_id", "region"]→.on("_id", "region").com.mongodb.):keepExisting→KEEP_EXISTING.$merge(into, pluson,whenMatchedandwhenNotMatched) and$out(coll).$unwindmoves toNAMEDwithincludeArrayIndexandpreserveNullAndEmptyArrays.$mergekey order:$mergejoins the named-argument operators in both comparison implementations (FormEquivalenceand core'sFormRules). The server ignores its key order, and Morphia writes a fixed one.{ $out: { db: "reporting", coll: ... } }), whichOperatorCaseRunnerrefuses because both behavior runs would share it;{ $merge: { into: "t" } }), which Morphia writes as the short form.$unwindis the exception, since the existingUNWIND_PATHrule covers it;on: ["_id"]), whichMergeCodecwrites ason: "_id".Result
Five new generated cases, integrated under Critter and then reflection (457 tests each, all passing):
$merge: "Merge Results from Multiple Collections" and "Only Insert New Data";$out: "Output to Same Database";$unwind:includeArrayIndexandpreserveNullAndEmptyArrays.The
$mergeand$outexamples query themoviessample dataset, which the tests don't load, so only their serialization is checked.Decisions for review
$mergeexamples with paired reads still don't generate. "Summarize Ratings", "Update/Replace Data" and "Use the Pipeline to Customize the Merge" are blocked by a compound$group_id, a date literal and$dateToString, not by$merge. Those are expression-binding work, so I left them for a separate step.$currentDate's aggregation alternative, also needs a document literal, so adding pipeline-update emission would generate nothing yet.$outdboption from the binding rather than keeping an option that every use would make a gap.keepExistingexposed a core bug:MergeCodecwrotekeep_existing, which the server rejects. The fix is Write $merge's keepExisting as the server spells it #4591, off master. No generated case here useskeepExisting; only the offline generator test does.Codex review: round 1 found the three failing-test spellings above, now gaps or rules with regression tests; round 2 was clean. The audits suite passes: 443 tests, 0 failures, 4 skipped.
Self-reviewed only.