aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2019-01-14 15:44:12 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2019-01-17 16:08:32 -0500
commit27b252d6a85e300c7236d034d55ec8e44f57a83e (patch)
treea6f994f483c8b61dd94be4c0f372ceb1f1bdc9f2 /activerecord
parent60c8a03c8d1e45e48fcb1055ba4c49ed3d5ff78f (diff)
downloadrails-27b252d6a85e300c7236d034d55ec8e44f57a83e.tar.gz
rails-27b252d6a85e300c7236d034d55ec8e44f57a83e.tar.bz2
rails-27b252d6a85e300c7236d034d55ec8e44f57a83e.zip
Remove deprecated `expand_hash_conditions_for_aggregates`
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md10
-rw-r--r--activerecord/lib/active_record/sanitization.rb37
-rw-r--r--activerecord/test/cases/sanitize_test.rb6
3 files changed, 7 insertions, 46 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index e987a0e279..e515d062fe 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,7 +1,11 @@
-* Set polymorphic type column to NULL on `dependent: :nullify` strategy.
-
+* Remove deprecated `expand_hash_conditions_for_aggregates`.
+
+ *Rafael Mendonça França*
+
+* Set polymorphic type column to NULL on `dependent: :nullify` strategy.
+
On polymorphic associations both the foreign key and the foreign type columns will be set to NULL.
-
+
*Laerti Papa*
* Allow `ActionController::Params` as argument of `ActiveRecord::Base#exists?`.
diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb
index 3485d9e557..e6197752bc 100644
--- a/activerecord/lib/active_record/sanitization.rb
+++ b/activerecord/lib/active_record/sanitization.rb
@@ -134,43 +134,6 @@ module ActiveRecord
end
private
- # Accepts a hash of SQL conditions and replaces those attributes
- # that correspond to a {#composed_of}[rdoc-ref:Aggregations::ClassMethods#composed_of]
- # relationship with their expanded aggregate attribute values.
- #
- # Given:
- #
- # class Person < ActiveRecord::Base
- # composed_of :address, class_name: "Address",
- # mapping: [%w(address_street street), %w(address_city city)]
- # end
- #
- # Then:
- #
- # { address: Address.new("813 abc st.", "chicago") }
- # # => { address_street: "813 abc st.", address_city: "chicago" }
- def expand_hash_conditions_for_aggregates(attrs) # :doc:
- expanded_attrs = {}
- attrs.each do |attr, value|
- if aggregation = reflect_on_aggregation(attr.to_sym)
- mapping = aggregation.mapping
- mapping.each do |field_attr, aggregate_attr|
- expanded_attrs[field_attr] = if value.is_a?(Array)
- value.map { |it| it.send(aggregate_attr) }
- elsif mapping.size == 1 && !value.respond_to?(aggregate_attr)
- value
- else
- value.send(aggregate_attr)
- end
- end
- else
- expanded_attrs[attr] = value
- end
- end
- expanded_attrs
- end
- deprecate :expand_hash_conditions_for_aggregates
-
def replace_bind_variables(statement, values)
raise_if_bind_arity_mismatch(statement, statement.count("?"), values.size)
bound = values.dup
diff --git a/activerecord/test/cases/sanitize_test.rb b/activerecord/test/cases/sanitize_test.rb
index 778cf86ac3..18b27bd6d1 100644
--- a/activerecord/test/cases/sanitize_test.rb
+++ b/activerecord/test/cases/sanitize_test.rb
@@ -168,12 +168,6 @@ class SanitizeTest < ActiveRecord::TestCase
assert_equal "#{ActiveRecord::Base.connection.quote('10')}::integer '2009-01-01'::date", l.call
end
- def test_deprecated_expand_hash_conditions_for_aggregates
- assert_deprecated do
- assert_equal({ "balance" => 50 }, Customer.send(:expand_hash_conditions_for_aggregates, balance: Money.new(50)))
- end
- end
-
private
def bind(statement, *vars)
if vars.first.is_a?(Hash)