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
friendlyfashion-thinking-sphinx-2.0.14.4 lib/thinking_sphinx/adapters/mysql_adapter.rb
friendlyfashion-thinking-sphinx-2.0.14.3 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-2.1.0 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.5.0 lib/thinking_sphinx/adapters/mysql_adapter.rb
friendlyfashion-thinking-sphinx-2.0.14.2 lib/thinking_sphinx/adapters/mysql_adapter.rb
friendlyfashion-thinking-sphinx-2.0.14.1 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-2.0.14 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.4.14 lib/thinking_sphinx/adapters/mysql_adapter.rb
friendlyfashion-thinking-sphinx-2.0.13.3 lib/thinking_sphinx/adapters/mysql_adapter.rb
friendlyfashion-thinking-sphinx-2.0.13.2 lib/thinking_sphinx/adapters/mysql_adapter.rb
friendlyfashion-thinking-sphinx-2.0.13.1 lib/thinking_sphinx/adapters/mysql_adapter.rb
friendlyfashion-thinking-sphinx-2.0.13 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-2.0.13 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.4.13 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-2.0.12 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.4.12 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-2.0.11 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.4.11 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-2.0.10 lib/thinking_sphinx/adapters/mysql_adapter.rb
thinking-sphinx-1.4.10 lib/thinking_sphinx/adapters/mysql_adapter.rb