diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2016-04-04 00:07:07 +0100 |
---|---|---|
committer | Andrew White <pixeltrix@users.noreply.github.com> | 2016-04-04 00:07:07 +0100 |
commit | 8040e55063abde6eeaac2702ca9961ce34a2d6c7 (patch) | |
tree | 929d35c0a0fd4337b2b529d6e12494affdb47fa2 /activerecord | |
parent | 9c2c677d903bcdea3feb1cad6c6d4c8c07cc8034 (diff) | |
parent | 9266d908f2434c9e792fbd4917c1536d1d30091c (diff) | |
download | rails-8040e55063abde6eeaac2702ca9961ce34a2d6c7.tar.gz rails-8040e55063abde6eeaac2702ca9961ce34a2d6c7.tar.bz2 rails-8040e55063abde6eeaac2702ca9961ce34a2d6c7.zip |
Merge pull request #24247 from ypxing/refactor_substitute_values
enhance ActiveRecord#substitute_values to loop values just once
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 777b593812..c0ed89fc97 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -94,12 +94,12 @@ module ActiveRecord end def substitute_values(values) # :nodoc: - binds = values.map do |arel_attr, value| - QueryAttribute.new(arel_attr.name, value, klass.type_for_attribute(arel_attr.name)) - end + binds = [] + substitutes = [] - substitutes = values.map do |(arel_attr, _)| - [arel_attr, Arel::Nodes::BindParam.new] + values.each do |arel_attr, value| + binds.push QueryAttribute.new(arel_attr.name, value, klass.type_for_attribute(arel_attr.name)) + substitutes.push [arel_attr, Arel::Nodes::BindParam.new] end [substitutes, binds] |