Sha256: 3ca201e23a33a84c35d902d18feb883cbd8c5f4215bb823e67cc52001120e273

Contents?: true

Size: 1.29 KB

Versions: 28

Compression:

Stored size: 1.29 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 cast_to_int(clause)
      "CAST(#{clause} AS SIGNED)"
    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
    
    def utc_query_pre
      "SET TIME_ZONE = '+0:00'"
    end
  end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
thinking-sphinx-2.0.9 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.4.9 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-2.0.8 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.4.8 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-2.0.7 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.4.7 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-2.0.5 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.4.6 lib/thinking_sphinx/adapters/mysql_adapter.rb