Commit 1058973f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rails5-boolean-cast' into 'master'

Fix boolean casting for nil value

Closes #46925

See merge request gitlab-org/gitlab-ce!19202
parents a51c5773 884fbf1d
......@@ -206,10 +206,11 @@ class Service < ActiveRecord::Base
args.each do |arg|
class_eval %{
def #{arg}?
# '!!' is used because nil or empty string is converted to nil
if Gitlab.rails5?
!ActiveModel::Type::Boolean::FALSE_VALUES.include?(#{arg})
!!ActiveRecord::Type::Boolean.new.cast(#{arg})
else
ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(#{arg})
!!ActiveRecord::Type::Boolean.new.type_cast_from_database(#{arg})
end
end
}
......
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