Commit 145832d6 authored by blackst0ne's avatar blackst0ne

[Rails5] Fix optimistic lock value

Update the monkey-patch to make it work in Rails 5.
parent fb08183e
---
title: "[Rails5] Fix optimistic lock value"
merge_request: 19878
author: "@blackst0ne"
type: fixed
# rubocop:disable Lint/RescueException
# Remove this entire initializer when we are at rails 5.0.
# This file fixes the bug (see below) which has been fixed in the upstream.
unless Gitlab.rails5?
# This patch fixes https://github.com/rails/rails/issues/26024
# TODO: Remove it when it's no longer necessary
module ActiveRecord
# Remove this monkey-patch when all lock_version values are converted from NULLs to zeros.
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/25228
module ActiveRecord
module Locking
module Optimistic
# We overwrite this method because we don't want to have default value
......@@ -68,6 +64,17 @@ unless Gitlab.rails5?
# This is patched because we want `lock_version` default to `NULL`
# rather than `0`
if Gitlab.rails5?
class LockingType
def deserialize(value)
super
end
def serialize(value)
super
end
end
else
class LockingType < SimpleDelegator
def type_cast_from_database(value)
super
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment