Module: ActiveRecord::ConnectionAdapters::Quoting::ClassMethods

Defined in:
lib/active_record/connection_adapters/abstract/quoting.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#column_name_matcherObject

Regexp for column names (with or without a table name prefix). Matches the following:

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


18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/active_record/connection_adapters/abstract/quoting.rb', line 18

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

#column_name_with_order_matcherObject

Regexp for column names with order (with or without a table name prefix, with or without various order modifiers). Matches the following:

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


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/active_record/connection_adapters/abstract/quoting.rb', line 44

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

#quote_column_name(column_name) ⇒ Object

Quotes the column name. Must be implemented by subclasses

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/active_record/connection_adapters/abstract/quoting.rb', line 61

def quote_column_name(column_name)
  raise NotImplementedError
end

#quote_table_name(table_name) ⇒ Object

Quotes the table name. Defaults to column name quoting.



66
67
68
# File 'lib/active_record/connection_adapters/abstract/quoting.rb', line 66

def quote_table_name(table_name)
  quote_column_name(table_name)
end