Sha256: 302615f5cde24dbbbb85de714409ad2869c61825a79c14293c0e5b07e1d37e52

Contents?: true

Size: 1.15 KB

Versions: 35

Compression:

Stored size: 1.15 KB

Contents

module ThinkingSphinx
  class MysqlAdapter < AbstractAdapter
    def setup
      # Does MySQL actually need to do anything?
    end
    
    def sphinx_identifier
      "mysql"
    end
    
    def concatenate(clause, separator = ' ')
      "CONCAT_WS('#{separator}', #{clause})"
    end
    
    def group_concatenate(clause, separator = ' ')
      "GROUP_CONCAT(DISTINCT IFNULL(#{clause}, '0') SEPARATOR '#{separator}')"
    end
    
    def cast_to_string(clause)
      "CAST(#{clause} AS CHAR)"
    end
    
    def cast_to_datetime(clause)
      "UNIX_TIMESTAMP(#{clause})"
    end
    
    def cast_to_unsigned(clause)
      "CAST(#{clause} AS UNSIGNED)"
    end
    
    def convert_nulls(clause, default = '')
      default = "'#{default}'" if default.is_a?(String)
      
      "IFNULL(#{clause}, #{default})"
    end
    
    def boolean(value)
      value ? 1 : 0
    end
    
    def crc(clause, blank_to_null = false)
      clause = "NULLIF(#{clause},'')" if blank_to_null
      "CRC32(#{clause})"
    end
    
    def utf8_query_pre
      "SET NAMES utf8"
    end
    
    def time_difference(diff)
      "DATE_SUB(NOW(), INTERVAL #{diff} SECOND)"
    end
  end
end

Version data entries

35 entries across 35 versions & 7 rubygems

Version Path
skalee-thinking-sphinx-1.3.14.2 lib/thinking_sphinx/adapters/mysql_adapter.rb
skalee-thinking-sphinx-1.3.14.1 lib/thinking_sphinx/adapters/mysql_adapter.rb
hawkerb-thinking-sphinx-1.3.18 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.3.17 lib/thinking_sphinx/adapters/mysql_adapter.rb
warp-thinking-sphinx-1.3.16 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.3.16 lib/thinking_sphinx/adapters/mysql_adapter.rb
hawkerb-thinking-sphinx-1.3.17 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.3.15 lib/thinking_sphinx/adapters/mysql_adapter.rb
hawkerb-thinking-sphinx-1.3.16 lib/thinking_sphinx/adapters/mysql_adapter.rb
hawkerb-thinking-sphinx-1.3.15 lib/thinking_sphinx/adapters/mysql_adapter.rb
hawkerb-thinking-sphinx-1.3.14 lib/thinking_sphinx/adapters/mysql_adapter.rb
zipme-thinking-sphinx-1.3.14 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.3.14 lib/thinking_sphinx/adapters/mysql_adapter.rb
warp-thinking-sphinx-1.3.13 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.3.13 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.3.12 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.3.11 lib/thinking_sphinx/adapters/mysql_adapter.rb
warp-thinking-sphinx-1.3.11 lib/thinking_sphinx/adapters/mysql_adapter.rb
warp-thinking-sphinx-1.3.10 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.3.10 lib/thinking_sphinx/adapters/mysql_adapter.rb