diff options
author | Matthew Draper <matthew@trebex.net> | 2014-07-06 16:50:54 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2014-07-06 16:50:54 +0930 |
commit | b974033790c4cec68750d95b4f9789033f7ac93c (patch) | |
tree | 8357e189744a38339c730a8dce039bdf6e6c6156 /activerecord/lib | |
parent | 93e24dea60368db17f92eac79122b36c30655297 (diff) | |
parent | 42be84ba40d95561554a4ccd62f482b028454025 (diff) | |
download | rails-b974033790c4cec68750d95b4f9789033f7ac93c.tar.gz rails-b974033790c4cec68750d95b4f9789033f7ac93c.tar.bz2 rails-b974033790c4cec68750d95b4f9789033f7ac93c.zip |
Merge pull request #16069 from dylanahsmith/mysql-quote-bool
active_record: Type cast booleans and durations for string columns.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/type/binary.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/type/string.rb | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/type/binary.rb b/activerecord/lib/active_record/type/binary.rb index 7416c554c7..d29ff4e494 100644 --- a/activerecord/lib/active_record/type/binary.rb +++ b/activerecord/lib/active_record/type/binary.rb @@ -24,7 +24,7 @@ module ActiveRecord class Data # :nodoc: def initialize(value) - @value = value + @value = value.to_s end def to_s diff --git a/activerecord/lib/active_record/type/string.rb b/activerecord/lib/active_record/type/string.rb index 8cc533bc41..e1791169d8 100644 --- a/activerecord/lib/active_record/type/string.rb +++ b/activerecord/lib/active_record/type/string.rb @@ -17,8 +17,10 @@ module ActiveRecord def type_cast_for_database(value) case value - when ::Numeric then value.to_s + when ::Numeric, ActiveSupport::Duration then value.to_s when ::String then ::String.new(value) + when true then "1" + when false then "0" else super end end |