Module: Switchman::Arel::Visitors::ToSql

Defined in:
lib/switchman/arel.rb

Instance Method Summary collapse

Instance Method Details

#quote_local_table_name(name) ⇒ Object

rubocop:enable Naming/MethodName rubocop:enable Naming/MethodParameterName



44
45
46
47
48
# File 'lib/switchman/arel.rb', line 44

def quote_local_table_name(name)
  return name if ::Arel::Nodes::SqlLiteral === name

  @connection.quote_local_table_name(name)
end

#visit_Arel_Attributes_Attribute(o, collector) ⇒ Object



36
37
38
39
# File 'lib/switchman/arel.rb', line 36

def visit_Arel_Attributes_Attribute(o, collector)
  join_name = o.relation.table_alias || o.relation.name
  collector << quote_local_table_name(join_name) << "." << quote_column_name(o.name)
end

#visit_Arel_Nodes_Cte(o, collector) ⇒ Object

rubocop:disable Naming/MethodName rubocop:disable Naming/MethodParameterName



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/switchman/arel.rb', line 16

def visit_Arel_Nodes_Cte(o, collector)
  collector << quote_local_table_name(o.name)
  collector << " AS "

  case o.materialized
  when true
    collector << "MATERIALIZED "
  when false
    collector << "NOT MATERIALIZED "
  end

  visit o.relation, collector
end

#visit_Arel_Nodes_TableAlias(o, collector) ⇒ Object



30
31
32
33
34
# File 'lib/switchman/arel.rb', line 30

def visit_Arel_Nodes_TableAlias(o, collector)
  collector = visit o.relation, collector
  collector << " "
  collector << quote_local_table_name(o.name)
end