aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-11-01 13:12:14 -0600
committerSean Griffin <sean@thoughtbot.com>2014-11-01 13:13:15 -0600
commit115cad36f432e51c0f805985a9202a28d62559d4 (patch)
treee93d3a776f0eb60bd23f23a4f2e92f62c438b712 /activerecord/lib/active_record
parent30c3813cf0851598aac2f41e51c72a0624e8cf23 (diff)
downloadrails-115cad36f432e51c0f805985a9202a28d62559d4.tar.gz
rails-115cad36f432e51c0f805985a9202a28d62559d4.tar.bz2
rails-115cad36f432e51c0f805985a9202a28d62559d4.zip
Don't needlessly alphabetize columns for insert/update
This slightly simplifies the code, and reduces the number of times we need to iterate over the attributes by one.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/relation.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 7f51e4134d..7d4a008f44 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -88,13 +88,12 @@ module ActiveRecord
end
def substitute_values(values) # :nodoc:
- substitutes = values.sort_by { |arel_attr,_| arel_attr.name }
- binds = substitutes.map do |arel_attr, value|
+ binds = values.map do |arel_attr, value|
[@klass.columns_hash[arel_attr.name], value]
end
- substitutes.each_with_index do |tuple, i|
- tuple[1] = @klass.connection.substitute_at(binds[i][0], i)
+ substitutes = values.each_with_index.map do |(arel_attr, _), i|
+ [arel_attr, @klass.connection.substitute_at(binds[i][0], i)]
end
[substitutes, binds]