diff options
author | Rick Xing <ypxing@gmail.com> | 2016-03-19 16:49:58 +1100 |
---|---|---|
committer | Rick Xing <ypxing@gmail.com> | 2016-03-19 16:49:58 +1100 |
commit | 9266d908f2434c9e792fbd4917c1536d1d30091c (patch) | |
tree | d98c2e274a1a563a4cad88337b1bfa46caac274b | |
parent | dda31d59a03adb7e5aa372e72bb66a3886632f2f (diff) | |
download | rails-9266d908f2434c9e792fbd4917c1536d1d30091c.tar.gz rails-9266d908f2434c9e792fbd4917c1536d1d30091c.tar.bz2 rails-9266d908f2434c9e792fbd4917c1536d1d30091c.zip |
enhance ActiveRecord#substitute_values to loop values just once
-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 09afdc6c69..426117992e 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] |