Class: Arel::Visitors::Spanner

Inherits:
ToSql
  • Object
show all
Defined in:
lib/arel/visitors/spanner.rb

Instance Method Summary collapse

Instance Method Details

#compile(node, collector = Arel::Collectors::SQLString.new) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/arel/visitors/spanner.rb', line 26

def compile node, collector = Arel::Collectors::SQLString.new
  collector.class.module_eval { attr_accessor :hints }
  collector.class.module_eval { attr_accessor :table_hints }
  collector.class.module_eval { attr_accessor :join_hints }
  collector.hints = {}
  collector.table_hints = {}
  collector.join_hints = {}

  sql, binds = accept(node, collector).value
  sql = collector.hints[:statement_hint].value + sql if collector.hints[:statement_hint]

  if binds
    binds << collector.hints[:staleness] if collector.hints[:staleness]
    binds << collector.hints[:request_options] if collector.hints[:request_options]
    [sql, binds]
  else
    sql
  end
end