Class: ThinkingSphinx::ActiveRecord::SQLBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/active_record/sql_builder.rb

Defined Under Namespace

Classes: ClauseBuilder, Query, Statement

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ SQLBuilder

Returns a new instance of SQLBuilder



6
7
8
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 6

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source



4
5
6
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 4

def source
  @source
end

Instance Method Details

#sql_queryObject



10
11
12
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 10

def sql_query
  statement.to_relation.to_sql.gsub(/\n/, "\\\n")
end

#sql_query_infoObject



19
20
21
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 19

def sql_query_info
  statement.to_query_info_relation.to_sql
end

#sql_query_post_indexObject



27
28
29
30
31
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 27

def sql_query_post_index
  return [] unless delta_processor && !source.delta?

  [delta_processor.reset_query]
end

#sql_query_preObject



23
24
25
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 23

def sql_query_pre
  query.to_query
end

#sql_query_rangeObject



14
15
16
17
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 14

def sql_query_range
  return nil if source.disable_range?
  statement.to_query_range_relation.to_sql
end