From fbdd58081e3d8a14bef68c824848571c873af21b Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Mon, 26 May 2014 07:01:53 -0700 Subject: Refactor the type casting of booleans in MySQL --- .../active_record/connection_adapters/abstract/quoting.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/abstract/quoting.rb') diff --git a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb index 169c00cb1a..768d2b6d36 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb @@ -55,8 +55,8 @@ module ActiveRecord case value when String, ActiveSupport::Multibyte::Chars value.to_s - when true then 't' - when false then 'f' + when true then unquoted_true + when false then unquoted_false when nil then nil # BigDecimals need to be put in a non-normalized form and quoted. when BigDecimal then value.to_s('F') @@ -101,10 +101,18 @@ module ActiveRecord "'t'" end + def unquoted_true + 't' + end + def quoted_false "'f'" end + def unquoted_false + 'f' + end + def quoted_date(value) if value.acts_like?(:time) zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal -- cgit v1.2.3