module ActiveRecord::ConnectionAdapters::Quoting::ClassMethods

def column_name_matcher

"#{column_name}"
"#{table_name}.#{column_name}"

Matches the following:
Regexp for column names (with or without a table name prefix).
:nodoc:
def column_name_matcher
  /
    \A
    (
      (?:
        # table_name.column_name | function(one or no argument)
        ((?:\w+\.)?\w+ | \w+\((?:|\g<2>)\))
      )
      (?:(?:\s+AS)?\s+\w+)?
    )
    (?:\s*,\s*\g<1>)*
    \z
  /ix
end

def column_name_with_order_matcher

"#{column_name} NULLS LAST"
"#{column_name} #{direction} NULLS FIRST"
"#{column_name} #{direction}"
"#{column_name}"
"#{table_name}.#{column_name} NULLS LAST"
"#{table_name}.#{column_name} #{direction} NULLS FIRST"
"#{table_name}.#{column_name} #{direction}"
"#{table_name}.#{column_name}"

with or without various order modifiers). Matches the following:
Regexp for column names with order (with or without a table name prefix,
def column_name_with_order_matcher
  /
    \A
    (
      (?:
        # table_name.column_name | function(one or no argument)
        ((?:\w+\.)?\w+ | \w+\((?:|\g<2>)\))
      )
      (?:\s+ASC|\s+DESC)?
      (?:\s+NULLS\s+(?:FIRST|LAST))?
    )
    (?:\s*,\s*\g<1>)*
    \z
  /ix
end

def quote_column_name(column_name)

Quotes the column name. Must be implemented by subclasses
def quote_column_name(column_name)
  raise NotImplementedError
end

def quote_table_name(table_name)

Quotes the table name. Defaults to column name quoting.
def quote_table_name(table_name)
  quote_column_name(table_name)
end