Sha256: fdf1e1e722a5cdf7d7cfcbc841ae359caaabcf71689a19b305a0404a6a6f2190

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

class ThinkingSphinx::ActiveRecord::DatabaseAdapters::PostgreSQLAdapter <
  ThinkingSphinx::ActiveRecord::DatabaseAdapters::AbstractAdapter

  def boolean_value(value)
    value ? 'TRUE' : 'FALSE'
  end

  def cast_to_bigint(clause)
    "#{clause}::bigint"
  end

  def cast_to_string(clause)
    "#{clause}::varchar"
  end

  def cast_to_timestamp(clause)
    if ThinkingSphinx::Configuration.instance.settings['64bit_timestamps']
      "extract(epoch from #{clause})::bigint"
    else
      "extract(epoch from #{clause})::int"
    end
  end

  def concatenate(clause, separator = ' ')
    clause.split(', ').collect { |part|
      convert_nulls(part, "''")
    }.join(" || '#{separator}' || ")
  end

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

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

  def group_concatenate(clause, separator = ' ')
    "array_to_string(array_agg(DISTINCT #{clause}), '#{separator}')"
  end

  def time_zone_query_pre
    ['SET TIME ZONE UTC']
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb
thinking-sphinx-3.4.0 lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb
thinking-sphinx-3.3.0 lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb
thinking-sphinx-3.2.0 lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb
thinking-sphinx-3.1.4 lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb
thinking-sphinx-3.1.3 lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb
thinking-sphinx-3.1.2 lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb