diff options
author | kamille-321 <yuji.kmjm@gmail.com> | 2019-02-19 11:50:31 +0900 |
---|---|---|
committer | kamille-321 <yuji.kmjm@gmail.com> | 2019-03-11 00:51:33 +0900 |
commit | 81bc621ed01637e8305fb53c9e504b1cc46c102f (patch) | |
tree | f0404468ccf06a3df9bd8fbd6bafb55a34ecce6d /activerecord/lib/active_record/attribute_methods/query.rb | |
parent | b75d6ea5d35d61c60f2675ed956c51e71d2b07ad (diff) | |
download | rails-81bc621ed01637e8305fb53c9e504b1cc46c102f.tar.gz rails-81bc621ed01637e8305fb53c9e504b1cc46c102f.tar.bz2 rails-81bc621ed01637e8305fb53c9e504b1cc46c102f.zip |
Fix query attribute method on user-defined attribute to be aware of typecasted value
change the line to check an attribute has user-defined type
ref: https://github.com/rails/rails/pull/35320#discussion_r257924552
check query attribute method is working when given value does not respond to to_i method
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/query.rb')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/query.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/query.rb b/activerecord/lib/active_record/attribute_methods/query.rb index 6757e9b66a..6811f54b10 100644 --- a/activerecord/lib/active_record/attribute_methods/query.rb +++ b/activerecord/lib/active_record/attribute_methods/query.rb @@ -16,8 +16,7 @@ module ActiveRecord when true then true when false, nil then false else - column = self.class.columns_hash[attr_name] - if column.nil? + if !type_for_attribute(attr_name) { false } if Numeric === value || value !~ /[^0-9]/ !value.to_i.zero? else |