Module: ActiveRecord::ConnectionAdapters::MySQL::Quoting::ClassMethods
- Defined in:
- lib/active_record/connection_adapters/mysql/quoting.rb
Overview
:nodoc:
Instance Method Summary collapse
- #column_name_matcher ⇒ Object
- #column_name_with_order_matcher ⇒ Object
- #quote_column_name(name) ⇒ Object
- #quote_table_name(name) ⇒ Object
Instance Method Details
#column_name_matcher ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/active_record/connection_adapters/mysql/quoting.rb', line 15 def column_name_matcher / \A ( (?: # `table_name`.`column_name` | function(one or no argument) ((?:\w+\.|`\w+`\.)?(?:\w+|`\w+`) | \w+\((?:|\g<2>)\)) ) (?:(?:\s+AS)?\s+(?:\w+|`\w+`))? ) (?:\s*,\s*\g<1>)* \z /ix end |
#column_name_with_order_matcher ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_record/connection_adapters/mysql/quoting.rb', line 30 def column_name_with_order_matcher / \A ( (?: # `table_name`.`column_name` | function(one or no argument) ((?:\w+\.|`\w+`\.)?(?:\w+|`\w+`) | \w+\((?:|\g<2>)\)) ) (?:\s+COLLATE\s+(?:\w+|"\w+"))? (?:\s+ASC|\s+DESC)? ) (?:\s*,\s*\g<1>)* \z /ix end |
#quote_column_name(name) ⇒ Object
46 47 48 |
# File 'lib/active_record/connection_adapters/mysql/quoting.rb', line 46 def quote_column_name(name) QUOTED_COLUMN_NAMES[name] ||= "`#{name.to_s.gsub('`', '``')}`".freeze end |
#quote_table_name(name) ⇒ Object
50 51 52 |
# File 'lib/active_record/connection_adapters/mysql/quoting.rb', line 50 def quote_table_name(name) QUOTED_TABLE_NAMES[name] ||= "`#{name.to_s.gsub('`', '``').gsub(".", "`.`")}`".freeze end |