activerecord-bitemporal
activerecord-bitemporal copied to clipboard
Apply irrelevant changes caused by touch
While doing some research, I noticed that models that include ActiveRecord::Bitemporal have unintended changes after being touched:
# bitemporal
employee.changes.keys # => []
employee.touch
employee.changes.keys # => ["valid_from", "transaction_from"]
employee.saved_changes.keys # => ["updated_at"]
# non-bitemporal
book.changes.keys # => []
book.touch
book,changes.keys # => []
book.saved_changes.keys # => ["updated_at"]
Perhaps adding changes unintentionally is not the expected behavior.
This PR changes the changes caused by touch to be moved saved_changes:
employee.changes.keys # => []
employee.touch
employee.changes.keys # => []
employee.saved_changes.keys # => ["valid_from", "transaction_from", "updated_at"]
As a side note, I noticed that unlike the non-bitemporal model, there was an issue where the dirty state before touch was unintentionally saved, but that's an issue that should be addressed in another PR.
This PR is frozen because #148 may fix this issue.