Commit 4afdfe76 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'blackst0ne-rails5-fix-optimistic-lock-values' into 'master'

[Rails5] Fix optimistic lock value

Closes #47961

See merge request gitlab-org/gitlab-ce!19878
parents 66bff49b 145832d6
---
title: "[Rails5] Fix optimistic lock value"
merge_request: 19878
author: "@blackst0ne"
type: fixed
# rubocop:disable Lint/RescueException # rubocop:disable Lint/RescueException
# Remove this entire initializer when we are at rails 5.0. # Remove this monkey-patch when all lock_version values are converted from NULLs to zeros.
# This file fixes the bug (see below) which has been fixed in the upstream. # See https://gitlab.com/gitlab-org/gitlab-ce/issues/25228
unless Gitlab.rails5? module ActiveRecord
# This patch fixes https://github.com/rails/rails/issues/26024
# TODO: Remove it when it's no longer necessary
module ActiveRecord
module Locking module Locking
module Optimistic module Optimistic
# We overwrite this method because we don't want to have default value # We overwrite this method because we don't want to have default value
...@@ -68,6 +64,17 @@ unless Gitlab.rails5? ...@@ -68,6 +64,17 @@ unless Gitlab.rails5?
# This is patched because we want `lock_version` default to `NULL` # This is patched because we want `lock_version` default to `NULL`
# rather than `0` # rather than `0`
if Gitlab.rails5?
class LockingType
def deserialize(value)
super
end
def serialize(value)
super
end
end
else
class LockingType < SimpleDelegator class LockingType < SimpleDelegator
def type_cast_from_database(value) def type_cast_from_database(value)
super 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