diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2014-11-01 14:39:59 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2014-11-01 14:39:59 -0600 |
commit | a431df84b5ccf9fe155f71cfd8b441523efde970 (patch) | |
tree | 9bb66ff00bec65c69fe2d2eb66aa64a7f6327d0c /activerecord/lib/active_record/relation/query_methods.rb | |
parent | acf314116c3913aa5165d440f8c7889776288974 (diff) | |
parent | 08579e4078454c6058f1289b58bf5bfa26661376 (diff) | |
download | rails-a431df84b5ccf9fe155f71cfd8b441523efde970.tar.gz rails-a431df84b5ccf9fe155f71cfd8b441523efde970.tar.bz2 rails-a431df84b5ccf9fe155f71cfd8b441523efde970.zip |
Merge pull request #17463 from mrgilman/remove-index-from-substitute-at
Remove redundant substitute index when constructing bind values
Diffstat (limited to 'activerecord/lib/active_record/relation/query_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 2c3cfb7631..d8d416416e 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -958,8 +958,7 @@ module ActiveRecord when Hash opts = PredicateBuilder.resolve_column_aliases(klass, opts) - bv_len = bind_values.length - tmp_opts, bind_values = create_binds(opts, bv_len) + tmp_opts, bind_values = create_binds(opts) self.bind_values += bind_values attributes = @klass.send(:expand_hash_conditions_for_aggregates, tmp_opts) @@ -971,7 +970,7 @@ module ActiveRecord end end - def create_binds(opts, idx) + def create_binds(opts) bindable, non_binds = opts.partition do |column, value| case value when String, Integer, ActiveRecord::StatementCache::Substitute @@ -984,9 +983,9 @@ module ActiveRecord new_opts = {} binds = [] - bindable.each_with_index do |(column,value), index| + bindable.each do |(column,value)| binds.push [@klass.columns_hash[column.to_s], value] - new_opts[column] = connection.substitute_at(column, index + idx) + new_opts[column] = connection.substitute_at(column) end non_binds.each { |column,value| new_opts[column] = value } |