diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-07-20 18:11:33 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-07-20 18:11:33 +0900 |
commit | 03afbc35b6586bd9a3b8b3e9f53d850c9ed49aa7 (patch) | |
tree | 79197e04743ed6641738beabfdbade689719127f /activerecord/lib/active_record | |
parent | 526d4b8dc816c17e354e2e0243af16d10147c3f0 (diff) | |
download | rails-03afbc35b6586bd9a3b8b3e9f53d850c9ed49aa7.tar.gz rails-03afbc35b6586bd9a3b8b3e9f53d850c9ed49aa7.tar.bz2 rails-03afbc35b6586bd9a3b8b3e9f53d850c9ed49aa7.zip |
Use `TRUE` and `FALSE` boolean literals for MySQL
Since #29699, abstract boolean serialization has been changed to use
`TRUE` and `FALSE` literals. MySQL also support the literals.
So we can use the abstract boolean serialization even for MySQL.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 10 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/quoting.rb | 10 |
2 files changed, 6 insertions, 14 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 06976aa769..92797fbeef 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "abstract_adapter" require_relative "statement_pool" require_relative "mysql/column" @@ -861,8 +863,8 @@ module ActiveRecord class MysqlString < Type::String # :nodoc: def serialize(value) case value - when true then MySQL::Quoting::QUOTED_TRUE - when false then MySQL::Quoting::QUOTED_FALSE + when true then "1" + when false then "0" else super end end @@ -871,8 +873,8 @@ module ActiveRecord def cast_value(value) case value - when true then MySQL::Quoting::QUOTED_TRUE - when false then MySQL::Quoting::QUOTED_FALSE + when true then "1" + when false then "0" else super end end diff --git a/activerecord/lib/active_record/connection_adapters/mysql/quoting.rb b/activerecord/lib/active_record/connection_adapters/mysql/quoting.rb index 4441c1e2f8..e0926ed6e6 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/quoting.rb @@ -2,8 +2,6 @@ module ActiveRecord module ConnectionAdapters module MySQL module Quoting # :nodoc: - QUOTED_TRUE, QUOTED_FALSE = "1".freeze, "0".freeze - def quote_column_name(name) @quoted_column_names[name] ||= "`#{super.gsub('`', '``')}`".freeze end @@ -12,18 +10,10 @@ module ActiveRecord @quoted_table_names[name] ||= super.gsub(".", "`.`").freeze end - def quoted_true - QUOTED_TRUE - end - def unquoted_true 1 end - def quoted_false - QUOTED_FALSE - end - def unquoted_false 0 end |