diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-11-02 13:34:52 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-11-02 13:34:52 -0700 |
commit | eb921000a11bc87a3b001164fc367b84aee584c5 (patch) | |
tree | a0ab73397535d0200e3b877c7851b4cd25d0ac12 | |
parent | d3fbd9dbb8f3c215c5364c07e32b5bc1d2497633 (diff) | |
download | rails-eb921000a11bc87a3b001164fc367b84aee584c5.tar.gz rails-eb921000a11bc87a3b001164fc367b84aee584c5.tar.bz2 rails-eb921000a11bc87a3b001164fc367b84aee584c5.zip |
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.
-rw-r--r-- | activerecord/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/sanitization.rb | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index ab85f2a472..5404465b4c 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,9 @@ +* 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`. diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb index 2c5cf944a4..d80b516c67 100644 --- a/activerecord/lib/active_record/sanitization.rb +++ b/activerecord/lib/active_record/sanitization.rb @@ -87,6 +87,9 @@ module ActiveRecord # { 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 @@ module ActiveRecord # { 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])}" |