aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-05-29 04:58:26 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-05-29 05:22:31 +0900
commit34cc301f03aea2e579d6687a9ea9782afc1089a0 (patch)
tree5dcef79348a0f189a7f19d4567c997a5fbc96fd9 /activemodel/lib
parent168598c0f1201fd310c972041919bede9f8f9511 (diff)
downloadrails-34cc301f03aea2e579d6687a9ea9782afc1089a0.tar.gz
rails-34cc301f03aea2e579d6687a9ea9782afc1089a0.tar.bz2
rails-34cc301f03aea2e579d6687a9ea9782afc1089a0.zip
Ensure casting by boolean attribute when querying
`QueryAttribute#value_for_database` calls only `type.serialize`, and `Boolean#serialize` is a no-op unlike other attribute types. It caused the issue #32624. Whether or not `serialize` will invoke `cast` is undefined in our test cases, but it actually does not work properly unless it does so for now. Fixes #32624.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/type/boolean.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/type/boolean.rb b/activemodel/lib/active_model/type/boolean.rb
index bcdbab0343..f6c6efbc87 100644
--- a/activemodel/lib/active_model/type/boolean.rb
+++ b/activemodel/lib/active_model/type/boolean.rb
@@ -20,6 +20,10 @@ module ActiveModel
:boolean
end
+ def serialize(value) # :nodoc:
+ cast(value)
+ end
+
private
def cast_value(value)