Fix editing issues and MRs with NULL lock_version
What does this MR do?
When we upgraded to Rails 5.1.7, we thought we could remove the monkey patch for handling NULL lock_versions since this bug was supposedly fixed in
https://github.com/rails/rails/pull/26050. However, that pull request does NOT fix the problem. The issue is that the value read in https://github.com/rails/rails/blob/8efdd545f3d40c6fa9ea615a196264f813c0c6b4/activerecord/lib/active_record/locking/optimistic.rb#L83 returns 0
rather than nil
. This
is used to signify what version the user got before making the change, rather than the raw value stored in the database.
This merge request also adds a test that shows https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24050 worked. We removed this in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/27480.
We can't re-add the patch as-is because the underlying code changed in Rails 5.1: https://github.com/rails/rails/blob/5-1-stable/activerecord/lib/active_record/locking/optimistic.rb