Class: ThinkingSphinx::SQLite3Adapter

Inherits:
AbstractAdapter show all
Defined in:
lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb

Instance Method Summary collapse

Methods inherited from AbstractAdapter

detect, #select_each

Instance Method Details

#boolean(value) ⇒ Object



37
38
39
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 37

def boolean(value)
  value ? "'t'" : "'f'"
end

#cast_to_datetime(clause) ⇒ Object



24
25
26
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 24

def cast_to_datetime(clause)
  "STRFTIME('%s', #{clause}, 'utc')"
end

#cast_to_string(clause) ⇒ Object



20
21
22
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 20

def cast_to_string(clause)
  "CAST(#{clause} AS TEXT)"
end

#cast_to_unsigned(clause) ⇒ Object



28
29
30
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 28

def cast_to_unsigned(clause)
  "CAST(#{clause} AS INTEGER)"
end

#concatenate(clause, separator = ' ') ⇒ Object



12
13
14
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_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
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 32

def convert_nulls(clause, default = '')
  default = "'#{default}'" if default.is_a?(String)
  "IFNULL(#{clause},#{default})"
end

#crc(clause, blank_to_null = false) ⇒ Object



41
42
43
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 41

def crc(clause, blank_to_null = false)
  "CRC32(#{clause})"
end

#group_concatenate(clause, separator = ' ') ⇒ Object



16
17
18
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 16

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

#setupObject



3
4
5
6
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 3

def setup
  create_group_concat_function
  create_crc32_function
end

#sphinx_identifierObject



8
9
10
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 8

def sphinx_identifier
  "sqlite3"
end

#time_difference(diff) ⇒ Object



49
50
51
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 49

def time_difference(diff)
  "STRFTIME('%s','now') - STRFTIME('%s', #{diff})"
end

#utf8_query_preObject



45
46
47
# File 'lib/thinking_sphinx/xml/adapters/sqlite3_adapter.rb', line 45

def utf8_query_pre
  nil
end