Skip to content
Permalink
Browse files

Deprecate `expand_hash_conditions_for_aggregates`

This can not expand an array of aggregated objects correctly, and is no
longer used internally since 159b21b.
  • Loading branch information...
kamipo committed Jan 29, 2018
1 parent bee7649 commit 7ae26885d96daee3809d0bd50b1a440c2f5ffb69
@@ -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.

```
@@ -169,6 +169,7 @@ def expand_hash_conditions_for_aggregates(attrs) # :doc:
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)
@@ -4,6 +4,7 @@
require "models/binary"
require "models/author"
require "models/post"
require "models/customer"

class SanitizeTest < ActiveRecord::TestCase
def setup
@@ -167,6 +168,12 @@ def test_named_bind_with_postgresql_type_casts
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)

0 comments on commit 7ae2688

Please sign in to comment.
You can’t perform that action at this time.