Class: ThinkingSphinx::ActiveRecord::DatabaseAdapters::PostgreSQLAdapter

Inherits:
AbstractAdapter
  • Object
show all
Defined in:
lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb

Instance Method Summary (collapse)

Methods inherited from AbstractAdapter

#initialize, #quote, #quoted_table_name, #utf8_query_pre

Constructor Details

This class inherits a constructor from ThinkingSphinx::ActiveRecord::DatabaseAdapters::AbstractAdapter

Instance Method Details

- (Object) boolean_value(value)



4
5
6
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 4

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

- (Object) cast_to_string(clause)



8
9
10
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 8

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

- (Object) cast_to_timestamp(clause)



12
13
14
15
16
17
18
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 12

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

- (Object) concatenate(clause, separator = ' ')



20
21
22
23
24
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 20

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

- (Object) convert_nulls(clause, default = '')



26
27
28
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 26

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

- (Object) group_concatenate(clause, separator = ' ')



30
31
32
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 30

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

- (Object) time_zone_query_pre



34
35
36
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 34

def time_zone_query_pre
  ['SET TIME ZONE UTC']
end