1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Deprecate expand_hash_conditions_for_aggregates

This can not expand an array of aggregated objects correctly, and is no
longer used internally since 159b21b5.
This commit is contained in:
Ryuta Kamizono 2018-01-29 21:28:42 +09:00
parent bee764965e
commit 7ae26885d9
3 changed files with 13 additions and 0 deletions

View file

@ -1,3 +1,8 @@
* Deprecate `expand_hash_conditions_for_aggregates` without replacement.
Using a `Relation` for performing queries is the prefered API.
*Ryuta Kamizono*
* Fix not expanded problem when passing an Array object as argument to the where method using `composed_of` column.
```

View file

@ -169,6 +169,7 @@ module ActiveRecord
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)

View file

@ -4,6 +4,7 @@ require "cases/helper"
require "models/binary"
require "models/author"
require "models/post"
require "models/customer"
class SanitizeTest < ActiveRecord::TestCase
def setup
@ -167,6 +168,12 @@ 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)