Skip to content

fix(dynamodb): SET complex RHS into nested paths#673

Merged
vieiralucas merged 1 commit intomainfrom
fix/dynamodb-nested-set-rhs
Apr 22, 2026
Merged

fix(dynamodb): SET complex RHS into nested paths#673
vieiralucas merged 1 commit intomainfrom
fix/dynamodb-nested-set-rhs

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 22, 2026

Summary

  • The nested-path SET branch short-circuited to plain resolve_value, so SET a.b = a.b + :d, SET a.b = list_append(a.b, :list), and SET a.b = if_not_exists(a.b, :v) all fell through to None and errored with ValidationException. Real DynamoDB allows every SET RHS shape against every SET LHS, including dotted paths.
  • Split SET's RHS evaluation out of the three apply_set_* helpers into a single evaluate_set_rhs that returns Option<Value>. The caller then picks a destination: item.insert (top-level), assign_list_index (indexed), or assign_nested_path (dotted).
  • resolve_ref_or_path replaces resolve_value as the single SET-side operand resolver: handles value refs (:x) and document paths (top-level, #name, dotted) by chaining resolve_projection_path with resolve_nested_path.
  • Unignore update_set_nested_path_complex_rhs and expand it to cover arithmetic (+/-), list_append, and both if_not_exists branches (skip-when-present, write-when-missing) through a dotted LHS.
  • Remove the now-obsolete update_set_nested_path_complex_rhs_errors_cleanly guard: its assertion ("dotted complex RHS must error") directly contradicts the positive test that now passes ("dotted arithmetic yields count = 8"). The positive test is strictly stronger coverage; silent-drop prevention is still locked in by the untouched update_set_nested_path_errors_on_missing_parent and by evaluate_arithmetic_rhs returning ValidationException on type mismatches.

Last of the 4 PRs (#670, #671, #672 already merged) that together close every #[ignore] in expression_corpus_tests.rs.

Test plan

  • cargo test -p fakecloud-dynamodb --lib (216 pass, 0 ignored — full corpus green)
  • cargo test -p fakecloud-e2e --test dynamodb (46 pass)
  • cargo clippy -p fakecloud-dynamodb --all-targets -- -D warnings
  • cargo fmt --all

Summary by cubic

Enables complex SET RHS on nested/dotted paths in DynamoDB updates (arithmetic, list_append, if_not_exists), fixing previous ValidationException errors and matching real DynamoDB behavior.

  • Bug Fixes

    • SET a.b = a.b +/- :d, SET a.b = list_append(a.b, :l), and SET a.b = if_not_exists(a.b, :v) now work with dotted paths and #name placeholders.
    • RHS operands can be value refs (:x) or document paths (top-level, #name, dotted).
    • Honors no-op behavior for if_not_exists when the target already has a value; structural path errors still surface.
  • Refactors

    • Added evaluate_set_rhs to compute RHS once and return Option<Value>; callers route to top-level insert, list index, or nested path.
    • Replaced resolve_value with resolve_ref_or_path by chaining resolve_projection_path and resolve_nested_path.
    • Unignored and expanded nested-path tests; removed the obsolete error-guard test.

Written for commit dd528ed. Summary will update on new commits.

- Split SET's RHS evaluation (if_not_exists, list_append, arithmetic, plain
  value) out of the three apply_set_* helpers and into a single
  evaluate_set_rhs that returns Option<Value>. The caller decides where to
  write: item.insert (top-level), assign_list_index (indexed), or
  assign_nested_path (dotted). Before: dotted LHS short-circuited to plain
  resolve_value, so `SET a.b = a.b + :d` / `list_append(a.b, :l)` /
  `if_not_exists(a.b, :v)` all fell through to None and errored.
- resolve_ref_or_path replaces resolve_value as the single SET-side operand
  resolver; it handles value refs (:x) and document paths (top-level,
  #name, dotted) by chaining resolve_projection_path with
  resolve_nested_path.
- Unignore update_set_nested_path_complex_rhs and expand it to cover
  arithmetic (+ and -), list_append, and both if_not_exists branches
  (skip-when-present, write-when-missing) through a dotted LHS.
- Remove the now-obsolete update_set_nested_path_complex_rhs_errors_cleanly
  guard: its assertion ("dotted complex RHS must error") directly
  contradicts the positive test that now passes ("dotted arithmetic yields
  count = 8").
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@vieiralucas vieiralucas merged commit 8245be9 into main Apr 22, 2026
48 checks passed
@vieiralucas vieiralucas deleted the fix/dynamodb-nested-set-rhs branch April 22, 2026 16:55
@vieiralucas vieiralucas mentioned this pull request Apr 22, 2026
3 tasks
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