class ThinkingSphinx::MysqlAdapter

Public Instance Methods

boolean(value) click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 41
def boolean(value)
  value ? 1 : 0
end
cast_to_datetime(clause) click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 23
def cast_to_datetime(clause)
  "UNIX_TIMESTAMP(#{clause})"
end
cast_to_int(clause) click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 31
def cast_to_int(clause)
  "CAST(#{clause} AS SIGNED)"
end
cast_to_string(clause) click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 19
def cast_to_string(clause)
  "CAST(#{clause} AS CHAR)"
end
cast_to_unsigned(clause) click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 27
def cast_to_unsigned(clause)
  "CAST(#{clause} AS UNSIGNED)"
end
concatenate(clause, separator = ' ') click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 11
def concatenate(clause, separator = ' ')
  "CONCAT_WS('#{separator}', #{clause})"
end
convert_nulls(clause, default = '') click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 35
def convert_nulls(clause, default = '')
  default = "'#{default}'" if default.is_a?(String)
  
  "IFNULL(#{clause}, #{default})"
end
crc(clause, blank_to_null = false) click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 45
def crc(clause, blank_to_null = false)
  clause = "NULLIF(#{clause},'')" if blank_to_null
  "CRC32(#{clause})"
end
group_concatenate(clause, separator = ' ') click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 15
def group_concatenate(clause, separator = ' ')
  "GROUP_CONCAT(DISTINCT IFNULL(#{clause}, '0') SEPARATOR '#{separator}')"
end
setup() click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 3
def setup
  # Does MySQL actually need to do anything?
end
sphinx_identifier() click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 7
def sphinx_identifier
  "mysql"
end
time_difference(diff) click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 54
def time_difference(diff)
  "DATE_SUB(NOW(), INTERVAL #{diff} SECOND)"
end
utc_query_pre() click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 58
def utc_query_pre
  "SET TIME_ZONE = '+0:00'"
end
utf8_query_pre() click to toggle source
# File lib/thinking_sphinx/adapters/mysql_adapter.rb, line 50
def utf8_query_pre
  "SET NAMES utf8"
end