Skip to content

Commit c1972c2

Browse files
authored
Merge pull request rails#29870 from kamipo/use_true_false_literals
Use `TRUE` and `FALSE` boolean literals for MySQL
2 parents af08044 + 03afbc3 commit c1972c2

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,8 @@ def version_string
863863
class MysqlString < Type::String # :nodoc:
864864
def serialize(value)
865865
case value
866-
when true then MySQL::Quoting::QUOTED_TRUE
867-
when false then MySQL::Quoting::QUOTED_FALSE
866+
when true then "1"
867+
when false then "0"
868868
else super
869869
end
870870
end
@@ -873,8 +873,8 @@ def serialize(value)
873873

874874
def cast_value(value)
875875
case value
876-
when true then MySQL::Quoting::QUOTED_TRUE
877-
when false then MySQL::Quoting::QUOTED_FALSE
876+
when true then "1"
877+
when false then "0"
878878
else super
879879
end
880880
end

activerecord/lib/active_record/connection_adapters/mysql/quoting.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ module ActiveRecord
44
module ConnectionAdapters
55
module MySQL
66
module Quoting # :nodoc:
7-
QUOTED_TRUE, QUOTED_FALSE = "1".freeze, "0".freeze
8-
97
def quote_column_name(name)
108
@quoted_column_names[name] ||= "`#{super.gsub('`', '``')}`".freeze
119
end
@@ -14,18 +12,10 @@ def quote_table_name(name)
1412
@quoted_table_names[name] ||= super.gsub(".", "`.`").freeze
1513
end
1614

17-
def quoted_true
18-
QUOTED_TRUE
19-
end
20-
2115
def unquoted_true
2216
1
2317
end
2418

25-
def quoted_false
26-
QUOTED_FALSE
27-
end
28-
2919
def unquoted_false
3020
0
3121
end

0 commit comments

Comments
 (0)