aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/statement_cache.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/statement_cache.rb')
-rw-r--r--activerecord/lib/active_record/statement_cache.rb20
1 files changed, 9 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/statement_cache.rb b/activerecord/lib/active_record/statement_cache.rb
index db7e0c8a04..64657089b5 100644
--- a/activerecord/lib/active_record/statement_cache.rb
+++ b/activerecord/lib/active_record/statement_cache.rb
@@ -41,20 +41,18 @@ module ActiveRecord
end
class PartialQuery < Query # :nodoc:
- def initialize(arel)
- @arel = arel
+ def initialize(values)
+ @values = values
+ @indexes = values.each_with_index.find_all { |thing, i|
+ Arel::Nodes::BindParam === thing
+ }.map(&:last)
end
def sql_for(binds, connection)
- val = @arel.dup
- val.grep(Arel::Nodes::BindParam) do |node|
- node.value = binds.shift
- if binds.empty?
- break
- end
- end
- sql, _ = connection.visitor.accept(val, connection.send(:collector)).value
- sql
+ val = @values.dup
+ casted_binds = binds.map(&:value_for_database)
+ @indexes.each { |i| val[i] = connection.quote(casted_binds.shift) }
+ val.join
end
end