aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2016-04-05 10:04:38 +0900
committeryui-knk <spiketeika@gmail.com>2016-04-05 10:04:38 +0900
commit72ecb9fc42fe0fe904b7c742036cdafa358c3cab (patch)
tree96f852a34d34324f8f9922a082aec9aa3a682c5c /activerecord/lib
parentbd49325e3ba9fba3bbea2d32b3e7a71ec1934c55 (diff)
downloadrails-72ecb9fc42fe0fe904b7c742036cdafa358c3cab.tar.gz
rails-72ecb9fc42fe0fe904b7c742036cdafa358c3cab.tar.bz2
rails-72ecb9fc42fe0fe904b7c742036cdafa358c3cab.zip
Use `QUOTED_TRUE` and `QUOTED_FALSE` instead of magic strings
Because we define `QUOTED_TRUE` as `"1"` and `QUOTED_FALSE` as `"0"`. And add test cases to ensure this commit does not break current behavior even if the value of `attributes_before_type_cast` is false.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
index 8015d1ed9e..f6766b996f 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
@@ -939,8 +939,8 @@ module ActiveRecord
class MysqlString < Type::String # :nodoc:
def serialize(value)
case value
- when true then "1"
- when false then "0"
+ when true then QUOTED_TRUE
+ when false then QUOTED_FALSE
else super
end
end
@@ -949,8 +949,8 @@ module ActiveRecord
def cast_value(value)
case value
- when true then "1"
- when false then "0"
+ when true then QUOTED_TRUE
+ when false then QUOTED_FALSE
else super
end
end