Skip to content

Commit

Permalink
Use self[] instead of build directly in predicate builder
Browse files Browse the repository at this point in the history
Don't call `arel_table[attr]` directly makes handling predicate building
easier in 3rd party code.
  • Loading branch information
kamipo committed Sep 1, 2020
1 parent 94ba417 commit 5dac9be
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions activerecord/lib/active_record/relation/predicate_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ def expand_from_hash(attributes, &block)
values = values.map do |object|
object.respond_to?(aggr_attr) ? object.public_send(aggr_attr) : object
end
build(table.arel_table[column_name], values)
self[column_name, values]
else
queries = values.map do |object|
mapping.map do |field_attr, aggregate_attr|
build(table.arel_table[field_attr], object.try!(aggregate_attr))
self[field_attr, object.try!(aggregate_attr)]
end
end

grouping_queries(queries)
end
else
build(table.arel_table[key], value)
self[key, value]
end
end
end
Expand Down

0 comments on commit 5dac9be

Please sign in to comment.