diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-04-06 13:39:55 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-04-06 13:39:55 +1100 |
commit | 59090f76c780c43c334cd75bf224afaf4f1cbb3c (patch) | |
tree | fdf23ce522b69341a79df1d95e75286b3ff54079 | |
parent | cfa716d6fe90802a05b5e130a271f404001c7916 (diff) | |
download | gitlab-ce-blackst0ne-rails5-fix-type-cast-for-from-database.tar.gz |
Fix sha_attributeblackst0ne-rails5-fix-type-cast-for-from-database
-rw-r--r-- | lib/gitlab/database/sha_attribute.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/gitlab/database/sha_attribute.rb b/lib/gitlab/database/sha_attribute.rb index a658bb8928b..770ea19a947 100644 --- a/lib/gitlab/database/sha_attribute.rb +++ b/lib/gitlab/database/sha_attribute.rb @@ -24,12 +24,18 @@ module Gitlab class ShaAttribute < BINARY_TYPE PACK_FORMAT = 'H*'.freeze - # It is called from activerecord-4.2.10/lib/active_record/attribute.rb + # It is called from activerecord-4.2.10/lib/active_record internal methods. # Remove this method when upgraded to rails 5.0 def type_cast_from_database(value) unpack_sha(super) end + # It is called from activerecord-4.2.10/lib/active_record internal methods. + # Remove this method when upgraded to rails 5.0 + def type_cast_for_database(value) + serialize(value) + end + # It is called from activerecord-5.0.6/lib/active_record/attribute.rb # Remove this method when upgraded to rails 5.0. def deserialize(value) @@ -50,7 +56,7 @@ module Gitlab def serialize(value) arg = value ? [value].pack(PACK_FORMAT) : nil - Gitlab.rails5? ? super(arg) : type_cast_for_database(arg) + Gitlab.rails5? ? super(arg) : method(:type_cast_for_database).super_method.call(arg) end end end |