Skip to content

Generate find and update cases from query and update pages - #4574

Open
evanchooly wants to merge 1 commit into
audits-example-namesfrom
audits-find-update
Open

evanchooly wants to merge 1 commit into
audits-example-namesfrom
audits-find-update

Conversation

@evanchooly

Copy link
Copy Markdown
Member

Step 5 of the operator-audit plan: find and update generation. Stacked on #4573.

Problem

The generator emitted only aggregation pipelines. Every unowned example on the query and update pages ($in, $type, $[], $[<identifier>], ...) was a gap reading "a FIND action is not generated yet" or "an UPDATE action is not generated yet".

Change

  • Runner. OperatorCaseRunner gains find(case, query -> ...) and update(case, query -> ..., UpdateOperator...) without a legacy-options check. The existing overloads check the legacy options, then delegate to these.
  • Generator. The emitter now handles each action shape:
    • a pipeline becomes runner.aggregate(...), as before;
    • a find becomes runner.find(case, (query) -> query.filter(gt("qty", 20))), reusing the $match filter emission from Generate $match, $group and $sort pipelines and sample-dataset cases #4572;
    • an update becomes runner.update(case, (query) -> query.filter(eq("_id", 1)), inc("qty", 2), set("tags", List.of("b"))), with one call per field.
  • Bindings. A new UPDATE position uses the FIELD form: $set, $inc, $mul, $max, $min, $unset, $rename, $addToSet, $push, $pull, $pullAll, all verified against core's API.
  • Values. Number and List parameters take literals. Query and update operands are data, so their arrays are List.of(...); array(...) stays for expression arguments.
  • Review. generation-review.json enables the query/filters and query/updates families.

Result

  • Two cases are generated, integrated under both mappers and promoted: $in's "Match Values in an Array" and $[]'s "Update All Elements in an Array". That makes 14 generated cases.
  • One exclusion: $[]'s "Update Arrays Specified Using a Negation Query Operator". Its serialization and behavior pass, but the page prints the whole collection after the update, while the runner's update results are the documents the filter still matches (the legacy convention). The reason is recorded, and "update results as the page reads them" is on the remaining-work list.
  • Remaining query and update gaps are mostly features: documented projections (5), and update options such as arrayFilters (5). Those are the plan's deferred cutover features, next.

Decisions for review

  • Exclude, don't change the runner's update results here. Changing them would change every converted update case's published check, so that belongs in its own change.
  • Field-only update factories ignore the value. $unset's unset(String, String...) emits unset("f"), and integration's strict serialization check would catch it if Morphia then wrote a different value than the page.

Verification

  • New GeneratorTest.findsAndUpdatesAreGenerated: a find and a multi-operator update emitted with the committed bindings, plus the projection and pipeline-update gaps.
  • Audits suite: 458 pass under Critter, then reflection.
  • Core operator tests: 692 pass under both mappers.

Self-reviewed only: the independent reviewers are out of quota until 2026-11-26.

The query/filters and query/updates families are generated: a find
becomes runner.find with the filter's Filters calls, an update
runner.update with the filter and one UpdateOperators call per field.
The runner gains option-free find and update overloads, and a new UPDATE
binding position covers the field update operators. Query and update
operands are data, so their arrays are lists rather than array
expressions.

Two cases are generated, integrated under both mappers and promoted; a
third is excluded because its page prints the whole collection after the
update, not the documents the filter still matches.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant