Repository navigation
Generate $lookup, comparison and boolean expressions, $replaceWith and $sortArray - #4599
Open
evanchooly wants to merge 1 commit into
Open
evanchooly wants to merge 1 commit into
evanchooly wants to merge 1 commit into
Conversation
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 #4598. Self-reviewed only.
What this solves
Three
$lookupsubquery examples, two$sortArrayexamples, and examples that use comparison or boolean expressions were gaps, though Morphia writes them all. For example,$lookup: { from: "stock", let: { name: "$item" }, pipeline: [ { $match: { $expr: { $and: [ { $eq: [ "$sku", "$$name" ] }, … ] } } } ], as: "stock" }stopped at "stage $lookup has no binding". Once that was bound, it stopped again at "$and has no binding".7 cases now generate (503 → 510):
$lookupsubquery examples;$sortArray;$unsetField;$filterlimit example.Integration: 522 tests under Critter, then reflection, 0 failures. Audits suite: 447 tests, 0 failures, 4 skipped. No committed case changed.
How
$lookup: a named stage,lookup(from), withlocalField,foreignField,as,letandpipelineoptions..let("a", x).let("b", y).Stage[]parameter takes a subpipeline's stages.$cmp,$gt,$gte,$lt,$lte,$ne,$and,$or,$arrayToObjectand$sortArray.$sortArray'ssortBydocument becomesSortvarargs.$replaceWith.$setFieldand$unsetFieldbind, and join that list in both rule ports.$andand$orwrite anExpressionList, an array even for one argument. So a one-item array is exact for them and a bare operand is a gap, as for$concatArrays.Gaps, each mirroring Morphia's behavior
$lookup:letwithout a pipeline, sinceLookupCodecwritesletonly beside one;$cmp,$gt,$gte,$ltor$lte, whose factories build aList.of;$setField/$unsetFieldargument, which their codecs drop.$setField: an expression as itsinput, whichSetFieldExpressionCodecwrites without opening its document.$key in a sort document ($natural), and an empty sort document.Decisions for review
$setField'sinputfails to encode. So does a document inside an array in aDocumentExpression, as in$lookup'slethere and document literals in Generate document literals, compound group ids, $cond and $concatArrays #4597. Both are only gaps here; they may deserve core issues.$replaceWith's "Pivot Sales by Quarter" groups without sorting, and the driver's run and Morphia's returned the groups in different orders. That's the second case to fail only on order (after$meta's text score in Generate find projections #4596). I recommend a separate PR that compares results unordered when a find or pipeline doesn't sort.$setField's two remaining examples need$literal, whose operand may itself be an array. That needs its own form.Review
Codex ran three local rounds, finding three, three and one issues. Each is now a gap with a regression case in
GeneratorTest. The design doc and the progress log are updated.