diff options
author | Dylan Thacker-Smith <Dylan.Smith@shopify.com> | 2019-01-17 14:16:13 -0500 |
---|---|---|
committer | Dylan Thacker-Smith <Dylan.Smith@shopify.com> | 2019-01-17 14:16:13 -0500 |
commit | b278db1d2361656c634c15c94ea981e6d0e327f9 (patch) | |
tree | 900c52660512beede0785ba65bd5397dc77fdc4e | |
parent | 242fc54f57d8db96eb2d34b1db19b9a61d7412b7 (diff) | |
download | rails-b278db1d2361656c634c15c94ea981e6d0e327f9.tar.gz rails-b278db1d2361656c634c15c94ea981e6d0e327f9.tar.bz2 rails-b278db1d2361656c634c15c94ea981e6d0e327f9.zip |
Avoid using yield_self to make it easier to backport
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index b8d64be343..842fb1c54b 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -91,12 +91,11 @@ module ActiveRecord elsif table.aggregated_with?(key) mapping = table.reflect_on_aggregation(key).mapping if mapping.length == 1 - mapping.first.yield_self do |field_attr, aggregate_attr| - values = Array.wrap(value).map do |object| - object.respond_to?(aggregate_attr) ? object.send(aggregate_attr) : object - end - build(table.arel_attribute(field_attr), values) + column_name, aggr_attr = mapping.first + values = Array.wrap(value).map do |object| + object.respond_to?(aggr_attr) ? object.send(aggr_attr) : object end + build(table.arel_attribute(column_name), values) else queries = Array.wrap(value).map do |object| mapping.map do |field_attr, aggregate_attr| |