From cfa716d6fe90802a05b5e130a271f404001c7916 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Fri, 6 Apr 2018 12:31:44 +1100 Subject: Fix sha_attribute --- lib/gitlab/database/sha_attribute.rb | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/gitlab/database/sha_attribute.rb b/lib/gitlab/database/sha_attribute.rb index 882e31e711f..a658bb8928b 100644 --- a/lib/gitlab/database/sha_attribute.rb +++ b/lib/gitlab/database/sha_attribute.rb @@ -6,7 +6,14 @@ module Gitlab # behaviour from the default Binary type. ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Bytea else - type_binary + # In Rails 5.0 `Type` has been moved from `ActiveRecord` to `ActiveModel` + # https://github.com/rails/rails/commit/9cc8c6f3730df3d94c81a55be9ee1b7b4ffd29f6#diff-f8ba7983a51d687976e115adcd95822b + # Remove this method and leave just `ActiveModel::Type::Binary` when upgraded to rails 5.0 + if Gitlab.rails5? + ActiveModel::Type::Binary + else + ActiveRecord::Type::Binary + end end # Class for casting binary data to hexadecimal SHA1 hashes (and vice-versa). @@ -46,18 +53,5 @@ module Gitlab Gitlab.rails5? ? super(arg) : type_cast_for_database(arg) end end - - private - - # In Rails 5.0 `Type` has been moved from `ActiveRecord` to `ActiveModel` - # https://github.com/rails/rails/commit/9cc8c6f3730df3d94c81a55be9ee1b7b4ffd29f6#diff-f8ba7983a51d687976e115adcd95822b - # Remove this method and leave just `ActiveModel::Type::Binary` when upgraded to rails 5.0 - def type_binary - if Gitlab.rails5? - ActiveModel::Type::Binary - else - ActiveRecord::Type::Binary - end - end end end -- cgit v1.2.1