module ActiveRecordMysqlIndexHint

Constants

VERSION

Public Instance Methods

force_index(*args) click to toggle source
# File lib/activerecord-mysql-index-hint.rb, line 8
def force_index(*args)
  from_with_index_hint 'FORCE', *args
end
ignore_index(*args) click to toggle source
# File lib/activerecord-mysql-index-hint.rb, line 12
def ignore_index(*args)
  from_with_index_hint 'IGNORE', *args
end
use_index(*args) click to toggle source
# File lib/activerecord-mysql-index-hint.rb, line 4
def use_index(*args)
  from_with_index_hint 'USE', *args
end

Private Instance Methods

from_with_index_hint(hint_type, *args) click to toggle source
# File lib/activerecord-mysql-index-hint.rb, line 17
def from_with_index_hint(hint_type, *args)
  return self if args.blank?
  indexes = args.map {|index| connection.quote_column_name index }
  self.from([Arel.sql("#{quoted_table_name} #{hint_type} INDEX(#{indexes.join(', ')})")])
end