Skip to content

Commit 7ae2688

Browse files
committed
Deprecate expand_hash_conditions_for_aggregates
This can not expand an array of aggregated objects correctly, and is no longer used internally since 159b21b.
1 parent bee7649 commit 7ae2688

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

activerecord/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Deprecate `expand_hash_conditions_for_aggregates` without replacement.
2+
Using a `Relation` for performing queries is the prefered API.
3+
4+
*Ryuta Kamizono*
5+
16
* Fix not expanded problem when passing an Array object as argument to the where method using `composed_of` column.
27

38
```

activerecord/lib/active_record/sanitization.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def expand_hash_conditions_for_aggregates(attrs) # :doc:
169169
end
170170
expanded_attrs
171171
end
172+
deprecate :expand_hash_conditions_for_aggregates
172173

173174
def replace_bind_variables(statement, values)
174175
raise_if_bind_arity_mismatch(statement, statement.count("?"), values.size)

activerecord/test/cases/sanitize_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require "models/binary"
55
require "models/author"
66
require "models/post"
7+
require "models/customer"
78

89
class SanitizeTest < ActiveRecord::TestCase
910
def setup
@@ -167,6 +168,12 @@ def test_named_bind_with_postgresql_type_casts
167168
assert_equal "#{ActiveRecord::Base.connection.quote('10')}::integer '2009-01-01'::date", l.call
168169
end
169170

171+
def test_deprecated_expand_hash_conditions_for_aggregates
172+
assert_deprecated do
173+
assert_equal({ "balance" => 50 }, Customer.send(:expand_hash_conditions_for_aggregates, balance: Money.new(50)))
174+
end
175+
end
176+
170177
private
171178
def bind(statement, *vars)
172179
if vars.first.is_a?(Hash)

0 commit comments

Comments
 (0)