diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-04-06 10:57:19 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-06 10:57:19 +0000 |
commit | 20695052db6860620365af9b86ab301759d1405d (patch) | |
tree | b7e8afd7953b5c92cbcee71d5c1fcef2178d0a31 /config | |
parent | 52b232ca5d18ffc08299f5bb0ef3be46d2fecca3 (diff) | |
download | gitlab-ce-20695052db6860620365af9b86ab301759d1405d.tar.gz |
[Rails5] Update `type_cast_*_database` methods
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/active_record_array_type_casting.rb | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/config/initializers/active_record_array_type_casting.rb b/config/initializers/active_record_array_type_casting.rb index d94d592add6..a149e048ee2 100644 --- a/config/initializers/active_record_array_type_casting.rb +++ b/config/initializers/active_record_array_type_casting.rb @@ -1,20 +1,23 @@ -module ActiveRecord - class PredicateBuilder - class ArrayHandler - module TypeCasting - def call(attribute, value) - # This is necessary because by default ActiveRecord does not respect - # custom type definitions (like our `ShaAttribute`) when providing an - # array in `where`, like in `where(commit_sha: [sha1, sha2, sha3])`. - model = attribute.relation&.engine - type = model.user_provided_columns[attribute.name] if model - value = value.map { |value| type.type_cast_for_database(value) } if type +# Remove this initializer when upgraded to Rails 5.0 +unless Gitlab.rails5? + module ActiveRecord + class PredicateBuilder + class ArrayHandler + module TypeCasting + def call(attribute, value) + # This is necessary because by default ActiveRecord does not respect + # custom type definitions (like our `ShaAttribute`) when providing an + # array in `where`, like in `where(commit_sha: [sha1, sha2, sha3])`. + model = attribute.relation&.engine + type = model.user_provided_columns[attribute.name] if model + value = value.map { |value| type.type_cast_for_database(value) } if type - super(attribute, value) + super(attribute, value) + end end - end - prepend TypeCasting + prepend TypeCasting + end end end end |