Change not to create history when destroying with force_update#135
Merged
wata727 merged 1 commit intokufu:masterfrom Jul 18, 2023
Merged
Change not to create history when destroying with force_update#135wata727 merged 1 commit intokufu:masterfrom
force_update#135wata727 merged 1 commit intokufu:masterfrom
Conversation
krororo
reviewed
Jul 18, 2023
| it { expect { subject }.not_to change(employee, :valid_to) } | ||
| it { expect { subject }.not_to change(employee, :transaction_from) } | ||
| it { expect { subject }.to change(employee, :transaction_to).from(ActiveRecord::Bitemporal::DEFAULT_TRANSACTION_TO).to(destroyed_time) } | ||
| it { expect { subject }.not_to change { Employee.ignore_valid_datetime.within_deleted.count } } |
Collaborator
Contributor
Author
There was a problem hiding this comment.
Makes sense. But ignore_valid_datetime.within_deleted is the standard way in the spec.
https://github.com/search?q=repo%3Akufu%2Factiverecord-bitemporal+ignore_valid_datetime.within_deleted&type=code
It would be nice to replace them all in someday.
krororo
approved these changes
Jul 18, 2023
Collaborator
krororo
left a comment
There was a problem hiding this comment.
I made a nits comment, but it looks good.
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.
This PR changes the
destroybehavior onforce_update. Previously, when destroying, the state before destruction was added as history.After this change, destruction performed within
force_updatewill no longer create history.This is an application of
force_update's "operate without saving history" property to destruction.This is useful for destruction without history if you accidentally creates a record. This is equivalent to
update_columns(transaction_to: Time.current), but is implemented as an Active Record interface to benefit from standard mechanisms such as callbacks.