diff options
author | Douwe Maan <douwe@selenight.nl> | 2018-12-27 15:46:57 +0100 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2018-12-27 15:59:19 +0100 |
commit | 82370345302426c9d854e78c2a32a56ab4eb6c47 (patch) | |
tree | 38447a22b8aeafab9e69ac70e6d6d1712e0a38c9 /config | |
parent | fd27be93489d7485754895ffef161431bf268b3d (diff) | |
download | gitlab-ce-82370345302426c9d854e78c2a32a56ab4eb6c47.tar.gz |
Support both 0 and NULL lock_versions
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/active_record_locking.rb | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/config/initializers/active_record_locking.rb b/config/initializers/active_record_locking.rb index b8e8a0427e5..1bd1a12e4b7 100644 --- a/config/initializers/active_record_locking.rb +++ b/config/initializers/active_record_locking.rb @@ -19,12 +19,7 @@ module ActiveRecord return 0 if attribute_names.empty? lock_col = self.class.locking_column - previous_lock_value = send(lock_col).to_i - - # This line is added as a patch - previous_lock_value = nil if previous_lock_value == '0' || previous_lock_value == 0 - increment_lock attribute_names += [lock_col] @@ -35,7 +30,8 @@ module ActiveRecord affected_rows = relation.where( self.class.primary_key => id, - lock_col => previous_lock_value + # Patched because when `lock_version` is read as `0`, it may actually be `NULL` in the DB. + lock_col => previous_lock_value == 0 ? [nil, 0] : previous_lock_value ).update_all( attributes_for_update(attribute_names).map do |name| [name, _read_attribute(name)] |