-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change not to create history when destroying with force_update
#135
Conversation
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 } } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a nits comment, but it looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR changes the
destroy
behavior onforce_update
. Previously, when destroying, the state before destruction was added as history.After this change, destruction performed within
force_update
will 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.