Sha256: 4dc8244aaf3c9d3fbbd5bb6924f86b0b10c355097df495b4751ccf2e37332944

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

class ThinkingSphinx::ActiveRecord::DatabaseAdapters::MySQLAdapter <
  ThinkingSphinx::ActiveRecord::DatabaseAdapters::AbstractAdapter

  def boolean_value(value)
    value ? 1 : 0
  end

  def cast_to_bigint(clause)
    "CAST(#{clause} AS UNSIGNED INTEGER)"
  end

  def cast_to_string(clause)
    "CAST(#{clause} AS char)"
  end

  def cast_to_timestamp(clause)
    "UNIX_TIMESTAMP(#{clause})"
  end

  def concatenate(clause, separator = ' ')
    "CONCAT_WS('#{separator}', #{clause})"
  end

  def convert_nulls(clause, default = '')
    "IFNULL(#{clause}, #{default})"
  end

  def convert_blank(clause, default = '')
    "COALESCE(NULLIF(#{clause}, ''), #{default})"
  end

  def group_concatenate(clause, separator = ' ')
    "GROUP_CONCAT(DISTINCT #{clause} SEPARATOR '#{separator}')"
  end

  def time_zone_query_pre
    ["SET TIME_ZONE = '+0:00'"]
  end

  def utf8_query_pre
    ["SET NAMES #{settings['mysql_encoding']}"]
  end

  private

  def settings
    ThinkingSphinx::Configuration.instance.settings
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb