Class: ActiveRecord::StatementCache::PartialQuery

Inherits:
Query
  • Object
show all
Defined in:
lib/active_record/statement_cache.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ PartialQuery

Returns a new instance of PartialQuery.



43
44
45
46
47
48
# File 'lib/active_record/statement_cache.rb', line 43

def initialize values
  @values = values
  @indexes = values.each_with_index.find_all { |thing,i|
    Arel::Nodes::BindParam === thing
  }.map(&:last)
end

Instance Method Details

#sql_for(binds, connection) ⇒ Object



50
51
52
53
54
55
# File 'lib/active_record/statement_cache.rb', line 50

def sql_for(binds, connection)
  val = @values.dup
  binds = connection.prepare_binds_for_database(binds)
  @indexes.each { |i| val[i] = connection.quote(binds.shift) }
  val.join
end