#515: Preserve original _id in overwrite and delete_one on decorated factbases#522
Closed
VasilevNStas wants to merge 1 commit into
Closed
#515: Preserve original _id in overwrite and delete_one on decorated factbases#522VasilevNStas wants to merge 1 commit into
VasilevNStas wants to merge 1 commit into
Conversation
Contributor
Author
|
@yegor256 please review |
Contributor
Author
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.
Description
Fbe.overwriteandFbe.delete_oneuse delete-and-recreate when the property already exists. On aFbe.fb-decorated factbase, theFactbase::Prehook assigns a fresh_id((max _id) + 1) on every insert, and the recreation loop skipped_idbecause it was already set. The original_idwas lost, breaking external references.Fix
Added
Fbe.unidhelper that removes the_idproperty from the fact's internal map after the Pre hook fires but before the recreation loop runs. The loop then sees_idas nil and restores the original value frombefore.Affected paths:
Fbe.overwritehash path (line 54-65)Fbe.overwritescalar path (line 86-98)Fbe.delete_one(line 34-42)Closes #515
Tests
test_preserves_id_on_decorated_fb— scalar overwrite on Fbe.fb-decorated factbase with 3 factstest_preserves_id_on_decorated_fb_with_hash— hash overwrite on decorated factbasetest_preserves_id_on_decorated_fb(delete_one) — delete_one on decorated factbaseVerification
bundle exec rubocop— 0 offensesbundle exec rake test— 286 tests, 0 failures