#469: Preserve hash additions in place#491
Conversation
GHX5T-SOL
left a comment
There was a problem hiding this comment.
Approved current head 1f43d72.
The patch matches #469: hash-form updates where every requested key is absent now assign onto the existing fact, mirroring the scalar absent-property path, while existing-property hash updates still take the delete/reinsert path. The new Factbase::Pre regression proves the absent-property hash case keeps the original pre-inserted position, so it catches the identity-changing behavior from the report.
Validation I ran locally on Ruby 3.3.11:
- bundle install with BUNDLE_PATH=/private/tmp/bundle-fbe-491
- bundle exec ruby -Itest test/fbe/test_overwrite.rb -- --no-cov -> 28 tests, 57 assertions, 0 failures
- bundle exec rubocop lib/fbe/overwrite.rb test/fbe/test_overwrite.rb -> 2 files inspected, no offenses
- ruby -c lib/fbe/overwrite.rb and ruby -c test/fbe/test_overwrite.rb -> Syntax OK
- bundle exec rake test -> 284 tests, 803 assertions, 0 failures, 9 skips
- git diff --check origin/master...HEAD -> clean
- diff-only gitleaks on lib/fbe/overwrite.rb and test/fbe/test_overwrite.rb -> clean
Hosted checks are also green, including Ubuntu/macOS rake.
|
@GHX5T-SOL Thanks for the review! You've earned +10 points for this contribution: +18 as a basis, -8 for absolutely no comments posted during the review. Your running score is +416; don't forget to check your Zerocracy account too. |
|
@akmhatey-ai merge conflict here |
|
Please fix the merge conflicts so this pull request can be merged. |
Fixes #469.
Fbe.overwritealready updates scalar-form absent properties on the existing fact. The hash form did not have the same absent-property path, so adding{ bar: 44 }destroyed and reinserted the fact even when all requested properties were missing.This change keeps the destroy/reinsert path for existing-property hash updates, but assigns the all-absent hash properties directly on the current fact. The regression test pins that identity-preserving behavior with
Factbase::Pre.Validation:
ruby -c lib/fbe/overwrite.rb->Syntax OKruby -c test/fbe/test_overwrite.rb->Syntax OKPASS origin/master reproduces issue: before pos=0, after pos=1PASS hash absent property preserved pos=0, foo=42, bar=44PASS existing-property hash path recreated pos=1, foo=55, bar=44, keep=yesgit diff --check origin/master...HEAD-> no outputgit diff origin/master...HEAD -- lib/fbe/overwrite.rb test/fbe/test_overwrite.rb | gitleaks stdin --no-banner --redact->no leaks foundactionlint,copyrights,markdown-lint,pdd,rakeon Ubuntu/macOS Ruby 3.3,reuse,typos,xcop, andyamllint.Limitations:
bundle exec ruby -Itest test/fbe/test_overwrite.rbandbundle exec rubocop lib/fbe/overwrite.rb test/fbe/test_overwrite.rbwere blocked in this Windows environment because Bundler was missing locked gems (rdoc 7.2.0,psych 5.3.1,parallel 2.0.1), and installingpsych 5.3.1failed due missingyaml.h/ MSYS2 keyring errors.rubocop lib/fbe/overwrite.rb test/fbe/test_overwrite.rbreported one unchanged pre-existing warning attest/fbe/test_overwrite.rb:16forLint/RedundantCopDisableDirective.