Class: ActiveRecord::StatementCache::PartialQuery

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Query

#retryable

Instance Method Summary collapse

Constructor Details

#initialize(values, retryable:) ⇒ PartialQuery

Returns a new instance of PartialQuery.



47
48
49
50
51
52
53
# File 'activerecord/lib/active_record/statement_cache.rb', line 47

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

Instance Method Details

#sql_for(binds, connection) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'activerecord/lib/active_record/statement_cache.rb', line 55

def sql_for(binds, connection)
  val = @values.dup
  @indexes.each do |i|
    value = binds.shift
    if ActiveModel::Attribute === value
      value = value.value_for_database
    end
    val[i] = connection.quote(value)
  end
  val.join
end