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.



8
9
10
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 8

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



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

def source
  @source
end

Instance Method Details

#sql_queryObject



12
13
14
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 12

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

#sql_query_preObject



21
22
23
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 21

def sql_query_pre
  query.to_query
end

#sql_query_rangeObject



16
17
18
19
# File 'lib/thinking_sphinx/active_record/sql_builder.rb', line 16

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