提交 c5e5dbed 编写于 作者: S Sean Griffin

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.
上级 8f8f8058
......@@ -107,7 +107,8 @@ def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name
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 @@ def replace_named_bind_variables(statement, bind_vars) #:nodoc:
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册