associations()
click to toggle source
def associations
@associations ||= ThinkingSphinx::ActiveRecord::Associations.new(model).tap do |assocs|
source.associations.reject(&:string?).each do |association|
assocs.add_join_to association.stack
end
end
end
config()
click to toggle source
def config
ThinkingSphinx::Configuration.instance
end
document_id()
click to toggle source
def document_id
quoted_alias = quote_column source.primary_key
"#{quoted_primary_key} * #{config.indices.count} + #{source.offset} AS #{quoted_alias}"
end
groupings()
click to toggle source
def groupings
groupings = source.groupings
if model.column_names.include?(model.inheritance_column)
groupings << quoted_inheritance_column
end
groupings
end
inheritance_column_condition()
click to toggle source
def inheritance_column_condition
"#{quoted_inheritance_column} = '#{model_name}'"
end
model_name()
click to toggle source
def model_name
klass = model.name
klass = klass.demodulize unless model.store_full_sti_class
klass
end
pre_select()
click to toggle source
def pre_select
('SQL_NO_CACHE ' if source.type == 'mysql').to_s
end
query()
click to toggle source
def query
Query.new(self)
end
quote_column(column)
click to toggle source
def quote_column(column)
model.connection.quote_column_name(column)
end
quoted_inheritance_column()
click to toggle source
def quoted_inheritance_column
"#{model.quoted_table_name}.#{quote_column(model.inheritance_column)}"
end
quoted_primary_key()
click to toggle source
def quoted_primary_key
"#{model.quoted_table_name}.#{quote_column(source.primary_key)}"
end
range_condition()
click to toggle source
def range_condition
condition = []
condition << "#{quoted_primary_key} BETWEEN $start AND $end" unless source.disable_range?
condition += source.conditions
condition
end
relation()
click to toggle source
def relation
model.unscoped
end
reversed_document_id()
click to toggle source
def reversed_document_id
"($id - #{source.offset}) / #{config.indices.count}"
end
statement()
click to toggle source
def statement
Statement.new(self)
end