Repository navigation
fix(edit): Calculate Field's preview shows the value a calculation rule leaves in the field (#2884) - #2904
Conversation
…eaves in the field (opengeos#2884)
…le leaves in the field (opengeos#2884)
…ld can't feel, and a test keeps its loss readings together (opengeos#2884)
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Code reviewI found no bugs, security problems or AGENTS.md breaks. The rule-first preview matches what Bugs: None found. Security: None found. Performance: None worth raising. The dialog re-runs the preview each frame for a layer with a calculation rule on the field. That now also parses the rules and clones the layer's field list for up to 3 rows. The cost is small, but it is new work on every frame. Confidence: low. Quality:
AGENTS.md: None found. The PR adds no command, parameter or interface text, so the command-surface, schema, translation and surface rules do not apply. Change sizeCompared with the base branch (merge base 23e0f14 to PR head 12ef1af). The comparison covers the whole PR, not only the latest push.
|
📖 Docs previewCommit |
Summary
Calculate Field's preview showed the expression's own result even when a calculation rule writes the same field and overwrites it on the run.
preview_calculationran the layer's calculation rules only to find a refusal and dropped their result, and ran them not at all for a layer with calculation rules and no checks.It now takes the value from the one-row copy after
calculation_rules(the function the run uses), and says what the last rule writing the field loses (WriteLosses::previewed). A rule on another field leaves the value and loss as they were. When a rule overwrites Calculate's result, the preview no longer shows what Calculate's own result lost; the run still says it in its notices. The docs paragraph on the preview (docs/user-guide/expressions.md) says so.No new command, parameter or interface text, so no translation, command-surface or schema change. The dialog still previews only its
PREVIEW_ROWS(3) rows. The one-row copy and the rules run only for a layer with a check or a calculation rule on the calculated field, since the dialog asks every frame; a layer with calculation rules on other fields only gets the expression's value, as before. The only caller is the Calculate Field dialog (also opened from the attribute table); a standalone table has no rules.Testing
calculate_field_preview_shows_what_a_calculation_rule_leaves_in_the_field(committed first; it failed on the old code withleft: [(Int(2), None), (Int(3), None), (Int(4), None)],right: [(Int(20), None), (Int(30), None), (Int(40), None)]). It checks, row by row, that the preview equals whatedit.calculateFieldleaves; a layer whose only design is a calculation rule; the later of two rules; a rule on another field; a fraction and an error from the rule's own write; a rule's clean result over Calculate's lossy one; a@row_numberrule; a rule that no longer reads; a rule on another field feeding a domain; no rule; no rows. A second test,a_losses_tally_previews_as_the_result_it_counts, keepsWriteLosses::previewedequal toLoss::previewedfor each kind of loss.cargo test -p rustgis-engine calculate_fieldand the wholerustgis-enginecrate;cargo clippy -p rustgis-engine --all-targets -- -D warnings;cargo fmt --all --check.origin/main(f5cf513) with this branch and the three other branches of this round (Command capabilities don't look inside an inlinemodel.rungraph #2758, Calculate Field's preview shows the expression's value when a calculation rule writes the same field #2884, [Bug]: A plugin command's dialog with a long help opens with only two rows of its fields in view #2816, overture.add from a plugin command in the desktop app answers no layers and adds nothing #2677) merged, in an English locale: pre-commit on every file,cargo fmt --check, clippy with-D warnings,cargo test --workspace(9577 passed, 0 failed),cargo xtask layers,cargo xtask schema --checkwith the fixtures checked against the schema and test hygiene,cargo xtask rows, and the Python package's tests (maturin + pytest, 49 passed). Not run here: the wasm32 build (no clang on this machine; CI's Web app job checks it), macOS and Windows.UI evidence
No layout or text change: the preview line and the dialog look as before, and only the value it shows differs when a rule writes the field, so there is no screenshot.
Related issue
Closes #2884
Summary by CodeRabbit
Bug Fixes
Documentation