diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-09 09:49:21 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-09 09:56:15 -0700 |
commit | 13772bfa49325a8dc26410d2dcb555665a320f92 (patch) | |
tree | 623890d306f92c8139ef507606611a0546eddcdf /activerecord/test/cases/reflection_test.rb | |
parent | c425d664247aa18239dae4c377dba5d397070249 (diff) | |
download | rails-13772bfa49325a8dc26410d2dcb555665a320f92.tar.gz rails-13772bfa49325a8dc26410d2dcb555665a320f92.tar.bz2 rails-13772bfa49325a8dc26410d2dcb555665a320f92.zip |
Properly persist `lock_version` as 0 if the DB has no default
The reason this bug occured is that we never actually check to see if
this column has changed from it's default, since it was never assigned
and is not mutable.
It appears I was wrong in b301c40224c6d15b539dbcc7485adb44d810f88c, with
my statement of "there is no longer a case where a given value would
differ from the default, but would not already be marked as changed."
However, I chose not to revert the deletion of
`initialize_internals_callback` from that commit, as I think a solution
closer to where the problem lies is less likely to get erroneously
removed. I'm not super happy with this solution, but it mirrors what is
being done in `_update_record`, and a fix for one should work for the
other.
I toyed with the idea of changing the definition of `changed?` on the
type to `changed_in_place?`. If we type cast the raw value, it'll break
a test about updating not modifying the lock column if nothing else was
changed. We could have the definition check if `raw_old_value` is `nil`,
but this feels fragile and less intention revealing. It would, however,
have the benefit of cleaning up old data that incorrectly persisted as
`nil`.
Fixes #18422
Diffstat (limited to 'activerecord/test/cases/reflection_test.rb')
0 files changed, 0 insertions, 0 deletions