Module: ActiveRecord::ConnectionAdapters::Quoting::ClassMethods
- Defined in:
- activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#column_name_matcher ⇒ Object
Regexp for column names (with or without a table name prefix).
-
#column_name_with_order_matcher ⇒ Object
Regexp for column names with order (with or without a table name prefix, with or without various order modifiers).
-
#quote_column_name(column_name) ⇒ Object
Quotes the column name.
-
#quote_table_name(table_name) ⇒ Object
Quotes the table name.
Instance Method Details
#column_name_matcher ⇒ Object
Regexp for column names (with or without a table name prefix). Matches the following:
"#{table_name}.#{column_name}"
"#{column_name}"
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/quoting.rb', line 17 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_matcher ⇒ Object
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"
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/quoting.rb', line 43 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
60 61 62 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/quoting.rb', line 60 def quote_column_name(column_name) raise NotImplementedError end |
#quote_table_name(table_name) ⇒ Object
Quotes the table name. Defaults to column name quoting.
65 66 67 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/quoting.rb', line 65 def quote_table_name(table_name) quote_column_name(table_name) end |