Repository navigation
Bind more expression operators and spread named varargs - #4601
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 #4600. Self-reviewed only.
What this does
Group 2 of the generator gaps: examples where Morphia has the API but the generator had no binding. 21 expression operators bind, and 14 more documented examples generate (511 to 525). Integration passes with 537 tests under each mapper.
New bindings:
$allElementsTrue,$anyElementTrue,$arrayElemAt(elementAt),$binarySize,$bsonSize,$divide,$literal,$ltrim,$not,$range,$rtrim,$setIntersection,$size,$stdDevPop,$stdDevSamp,$strLenCP,$subtract,$trim,$tsIncrement,$typeand$zip.Generator changes, each with the case it fixes
{$zip: {inputs: ["$a", "$b"]}}had no form, becausezip(Object...)takes its inputs as varargs. A named argument whose parameter is the factory'sObjectvarargs now spreads its array, givingzip("$a", "$b"). An empty array and a lonenull, which Java reads as the varargs array itself, are gaps.not(x),allElementsTrue(x)andanyElementTrue(x)write[x], while pages often write{$not: x}. These now join the always-array set: a one-item array is exact, and a bare operand getsSINGLE_ARGUMENT_ARRAY. That rule now lists all three, in bothFormEquivalence.ktandFormRules.java.{$trim: {chars: {$literal: "x"}}}generatedchars(literal("x")), which doesn't compile becausechars(String)takes only a string.{$convert: {to: {$literal: "string"}}}hits the same problem withConvertType. An operator is now generated only where the parameter takes an expression (Object,Expression, or a DSL type built from operators); anywhere else it is a gap.$literaloperand holding a$key: the generator would translate it as an operator, and encoding fails.$arrayElemAt,$divideor$subtract, whose factories build aList.of.$trim,$ltrimand$rtrimjoin the named-argument operators, because the server readsinputandcharsin either order.Reviewed exclusions (page errors)
Five more examples generate but fail behavior. In each, Morphia's result is the server's correct answer and the page is wrong:
divide/divideHoursIntoWorkdays: seedsconferencePlanningbut aggregatesplanning.binarySize/findLargestBinaryDataandbsonSize/returnDocumentWithLargestSpecifiedField: the pipelines sort and$limit: 1, but the pages print every document from the first stage. ThebsonSizesizes are also off (152 vs the server's 140).reduce/discountedMerchandise: prints ObjectId_ids for integer seeds.regexFind/useCapturedGroupingsToParseUserName: prints the$addFieldsoutput, not the result after$set.Decisions to review
SINGLE_ARGUMENT_ARRAYnow covers$not,$allElementsTrueand$anyElementTrue. This assumes the server reads{$not: x}and{$not: [x]}the same, which holds for expression$not. The rule already skips query positions, such as$match's{a: {$not: …}}.$graphLookup'srestrictSearchWithMatch, so it would rewrite a query$notthere.$sizealready has the same exposure.$graphLookuphas no binding, so nothing reaches that position today. I left it for when$graphLookupbinds.$filterwith$zip, which needs$let; that would need a new form.$median/$percentile, whose pages passmethod, which Morphia fixes.$mergeObjectsand$dateToString, whose factories are builders.Review
Codex: 3 rounds. Round 1 found 5 issues (4 fixed, 1 deferred as above), round 2 found 2 and round 3 found 1, all fixed. Design docs updated: the progress entry and the
SINGLE_ARGUMENT_ARRAYrow inoperator-audits-form-migration.md.