From 72ecb9fc42fe0fe904b7c742036cdafa358c3cab Mon Sep 17 00:00:00 2001 From: yui-knk Date: Tue, 5 Apr 2016 10:04:38 +0900 Subject: 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. --- .../active_record/connection_adapters/abstract_mysql_adapter.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activerecord/lib') 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 -- cgit v1.2.3