Class: Arel::Sql::TableReference

Inherits:
Formatter show all
Defined in:
lib/arel/engines/sql/formatters.rb

Instance Attribute Summary

Attributes inherited from Formatter

#christener, #engine, #environment

Instance Method Summary collapse

Methods inherited from Formatter

#initialize, #name_for, #quote, #quote_column_name, #quote_table_name

Constructor Details

This class inherits a constructor from Arel::Sql::Formatter

Instance Method Details

#select(select_sql, table) ⇒ Object



110
111
112
# File 'lib/arel/engines/sql/formatters.rb', line 110

def select(select_sql, table)
  "(#{select_sql}) #{quote_table_name(name_for(table))}"
end

#table(table) ⇒ Object



114
115
116
117
118
119
120
121
122
# File 'lib/arel/engines/sql/formatters.rb', line 114

def table(table)
  table_name = table.name
  return table_name if table_name =~ /\s/

  unique_name = name_for(table)

  quote_table_name(table_name) +
    (table_name != unique_name ? " #{quote_table_name(unique_name)}" : '')
end