Class: ThinkingSphinx::PostgreSQLAdapter
Instance Method Summary
collapse
detect, #initialize, #quote_with_table
Instance Method Details
#boolean(value) ⇒ Object
46
47
48
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 46
def boolean(value)
value ? 'TRUE' : 'FALSE'
end
|
#cast_to_datetime(clause) ⇒ Object
31
32
33
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 31
def cast_to_datetime(clause)
"cast(extract(epoch from #{clause}) as int)"
end
|
#cast_to_string(clause) ⇒ Object
27
28
29
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 27
def cast_to_string(clause)
clause
end
|
#cast_to_unsigned(clause) ⇒ Object
35
36
37
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 35
def cast_to_unsigned(clause)
clause
end
|
#concatenate(clause, separator = ' ') ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 12
def concatenate(clause, separator = ' ')
clause.split(', ').collect { |field|
case field
when /COALESCE/, "'')"
field
else
"COALESCE(CAST(#{field} as varchar), '')"
end
}.join(" || '#{separator}' || ")
end
|
#convert_nulls(clause, default = '') ⇒ Object
39
40
41
42
43
44
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 39
def convert_nulls(clause, default = '')
default = "'#{default}'" if default.is_a?(String)
default = 'NULL' if default.nil?
"COALESCE(#{clause}, #{default})"
end
|
#crc(clause, blank_to_null = false) ⇒ Object
50
51
52
53
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 50
def crc(clause, blank_to_null = false)
clause = "NULLIF(#{clause},'')" if blank_to_null
"crc32(#{clause})"
end
|
#group_concatenate(clause, separator = ' ') ⇒ Object
23
24
25
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 23
def group_concatenate(clause, separator = ' ')
"array_to_string(array_accum(#{clause}), '#{separator}')"
end
|
#setup ⇒ Object
3
4
5
6
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 3
def setup
create_array_accum_function
create_crc32_function
end
|
#sphinx_identifier ⇒ Object
8
9
10
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 8
def sphinx_identifier
"pgsql"
end
|
#time_difference(diff) ⇒ Object
59
60
61
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 59
def time_difference(diff)
"current_timestamp - interval '#{diff} seconds'"
end
|
#utf8_query_pre ⇒ Object
55
56
57
|
# File 'lib/thinking_sphinx/adapters/postgresql_adapter.rb', line 55
def utf8_query_pre
nil
end
|