Class: SQLTree::Node::IndexHint
- Defined in:
- lib/active_record/turntable/sql_tree_patch.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hint_method, hint_key, index_list) ⇒ IndexHint
constructor
A new instance of IndexHint.
- #to_sql(options = {}) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(hint_method, hint_key, index_list) ⇒ IndexHint
Returns a new instance of IndexHint.
200 201 202 203 204 |
# File 'lib/active_record/turntable/sql_tree_patch.rb', line 200 def initialize(hint_method, hint_key, index_list) @hint_method = hint_method @hint_key = hint_key @index_list = index_list end |
Class Method Details
.parse(tokens) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/active_record/turntable/sql_tree_patch.rb', line 212 def self.parse(tokens) hint_method = tokens.next.literal if tokens.peek.index_keyword? hint_key = tokens.next.literal tokens.consume(SQLTree::Token::LPAREN) index_list = parse_list(tokens, SQLTree::Node::Expression::Field) tokens.consume(SQLTree::Token::RPAREN) self.new(hint_method, hint_key, index_list) else raise SQLTree::Parser::UnexpectedToken, tokens.current end end |
Instance Method Details
#to_sql(options = {}) ⇒ Object
206 207 208 209 210 |
# File 'lib/active_record/turntable/sql_tree_patch.rb', line 206 def to_sql( = {}) sql = "#{hint_method} #{hint_key} " sql << "(#{index_list.map(&:to_sql).join(' ')})" sql end |