Class: ThinkingSphinx::OracleAdapter
Instance Method Summary
collapse
detect, #initialize, #quote_with_table
Instance Method Details
#boolean(value) ⇒ Object
38
39
40
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 38
def boolean(value)
value ? '1' : '0'
end
|
#cast_to_datetime(clause) ⇒ Object
24
25
26
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 24
def cast_to_datetime(clause)
"(TO_DATE(TO_CHAR(#{clause}, 'YYYY-MON-DD HH24.MI.SS'), 'YYYY-MON-DD HH24.MI.SS') - TO_DATE('01-JAN-1970','DD-MON-YYYY')) * (86400)"
end
|
#cast_to_string(clause) ⇒ Object
20
21
22
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 20
def cast_to_string(clause)
"TO_CHAR(#{clause})"
end
|
#cast_to_unsigned(clause) ⇒ Object
28
29
30
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 28
def cast_to_unsigned(clause)
"CAST(#{clause} AS NUMBER(10,0))"
end
|
#concatenate(clause, separator = ' ') ⇒ Object
12
13
14
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 12
def concatenate(clause, separator = ' ')
clause.split(', ').collect { |field| field }.join(" || '#{separator}' || ")
end
|
#convert_nulls(clause, default = '') ⇒ Object
32
33
34
35
36
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 32
def convert_nulls(clause, default = '')
return clause if default == ''
default = "'#{default}'" if default.is_a?(String)
"COALESCE(#{clause}, #{default})"
end
|
#crc(clause, blank_to_null = false) ⇒ Object
43
44
45
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 43
def crc(clause, blank_to_null = false)
"CRC32(#{clause})"
end
|
#group_concatenate(clause, separator = ' ') ⇒ Object
16
17
18
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 16
def group_concatenate(clause, separator = ' ')
"TO_STRING(CAST(COLLECT(TO_CHAR(#{clause})) AS SYS.ODCIVARCHAR2LIST), '#{separator}')"
end
|
#select_each(query) ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 55
def select_each(query)
cursor = connection.raw_connection.exec(query)
col_names = cursor.get_col_names.collect(&:downcase)
while values = cursor.fetch
hash_values = Hash[*col_names.zip(values).flatten]
yield hash_values
end
cursor.close
end
|
#setup ⇒ Object
3
4
5
6
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 3
def setup
create_group_concat_function
create_crc32_function
end
|
#sphinx_identifier ⇒ Object
8
9
10
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 8
def sphinx_identifier
"odbc"
end
|
#time_difference(diff) ⇒ Object
51
52
53
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 51
def time_difference(diff)
"SYSDATE - #{diff}/(86400)"
end
|
#utf8_query_pre ⇒ Object
47
48
49
|
# File 'lib/thinking_sphinx/adapters/oracle_adapter.rb', line 47
def utf8_query_pre
nil
end
|