Class: ThinkingSphinx::ActiveRecord::DatabaseAdapters::PostgreSQLAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ThinkingSphinx::ActiveRecord::DatabaseAdapters::PostgreSQLAdapter
show all
- Defined in:
- lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb
Instance Method Summary
collapse
#initialize, #quote, #quoted_table_name, #utf8_query_pre
Instance Method Details
#boolean_value(value) ⇒ Object
6
7
8
|
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 6
def boolean_value(value)
value ? 'TRUE' : 'FALSE'
end
|
#cast_to_bigint(clause) ⇒ Object
10
11
12
|
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 10
def cast_to_bigint(clause)
"#{clause}::bigint"
end
|
#cast_to_string(clause) ⇒ Object
14
15
16
|
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 14
def cast_to_string(clause)
"#{clause}::varchar"
end
|
#cast_to_timestamp(clause) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 18
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
|
#concatenate(clause, separator = ' ') ⇒ Object
26
27
28
29
30
|
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 26
def concatenate(clause, separator = ' ')
clause.split(', ').collect { |part|
convert_nulls(part, "''")
}.join(" || '#{separator}' || ")
end
|
#convert_blank(clause, default = '') ⇒ Object
36
37
38
|
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 36
def convert_blank(clause, default = '')
"COALESCE(NULLIF(#{clause}, ''), #{default})"
end
|
#convert_nulls(clause, default = '') ⇒ Object
32
33
34
|
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 32
def convert_nulls(clause, default = '')
"COALESCE(#{clause}, #{default})"
end
|
#group_concatenate(clause, separator = ' ') ⇒ Object
40
41
42
|
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 40
def group_concatenate(clause, separator = ' ')
"array_to_string(array_agg(DISTINCT #{clause}), '#{separator}')"
end
|
#time_zone_query_pre ⇒ Object
44
45
46
|
# File 'lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb', line 44
def time_zone_query_pre
['SET TIME ZONE UTC']
end
|