diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-01 09:05:26 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-01 09:09:20 -0700 |
commit | c5e5dbed1c2f9af86f737e672ec9af1415571165 (patch) | |
tree | c7ace38dc1d12ce368a4952a0f76d9294156c413 /activerecord/lib | |
parent | 8f8f8058e58dda20259c1caa61ec92542573643d (diff) | |
download | rails-c5e5dbed1c2f9af86f737e672ec9af1415571165.tar.gz rails-c5e5dbed1c2f9af86f737e672ec9af1415571165.tar.bz2 rails-c5e5dbed1c2f9af86f737e672ec9af1415571165.zip |
Stop using the column for type information in sanitization
As we move towards removing the types from the column objects, any
remaining places which have access to richer type information should be
using it.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/sanitization.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb index cfe99072ca..f5aa60a69a 100644 --- a/activerecord/lib/active_record/sanitization.rb +++ b/activerecord/lib/active_record/sanitization.rb @@ -107,7 +107,8 @@ sanitize_sql_hash_for_conditions is deprecated, and will be removed in Rails 5.0 def sanitize_sql_hash_for_assignment(attrs, table) c = connection attrs.map do |attr, value| - "#{c.quote_table_name_for_assignment(table, attr)} = #{quote_bound_value(value, c, columns_hash[attr.to_s])}" + value = type_for_attribute(attr.to_s).type_cast_for_database(value) + "#{c.quote_table_name_for_assignment(table, attr)} = #{c.quote(value)}" end.join(', ') end @@ -163,10 +164,8 @@ sanitize_sql_hash_for_conditions is deprecated, and will be removed in Rails 5.0 end end - def quote_bound_value(value, c = connection, column = nil) #:nodoc: - if column - c.quote(value, column) - elsif value.respond_to?(:map) && !value.acts_like?(:string) + def quote_bound_value(value, c = connection) #:nodoc: + if value.respond_to?(:map) && !value.acts_like?(:string) if value.respond_to?(:empty?) && value.empty? c.quote(nil) else |