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

Deprecate `sanitize_sql_hash_` methods on ActiveRecord

These appear to be implementation relics of times past. They duplicate
the logic in Relation, and are no longer used internally.
上级 d3fbd9db
* Deprecate `sanitize_sql_hash_for_conditions` and
`sanitize_sql_hash_for_assignment` without replacement. Using a `Relation`
for performing queries and updates is the prefered API.
*Sean Griffin*
* Queries now properly type cast values that are part of a join statement,
even when using type decorators such as `serialize`.
......
......@@ -87,6 +87,9 @@ def expand_hash_conditions_for_aggregates(attrs)
# { address: Address.new("123 abc st.", "chicago") }
# # => "address_street='123 abc st.' and address_city='chicago'"
def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name)
ActiveSupport::Deprecation.warn(<<-EOWARN)
sanitize_sql_hash_for_conditions is deprecated, and will be removed in Rails 5.0
EOWARN
attrs = PredicateBuilder.resolve_column_aliases self, attrs
attrs = expand_hash_conditions_for_aggregates(attrs)
......@@ -101,6 +104,9 @@ def sanitize_sql_hash_for_conditions(attrs, default_table_name = self.table_name
# { status: nil, group_id: 1 }
# # => "status = NULL , group_id = 1"
def sanitize_sql_hash_for_assignment(attrs, table)
ActiveSupport::Deprecation.warn(<<-EOWARN)
sanitize_sql_hash_for_assignment is deprecated, and will be removed in Rails 5.0
EOWARN
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])}"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册