Sha256: 4b6303eef20143cc08edf8065d7c3dbfa03199a0f10a23af75a2e22e19b7b63c

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

module ThinkingSphinx
  module ActiveRecord
    class SQLBuilder::Query
      def initialize(report)
        self.report = report
        self.scope = []
      end

      def to_query
        filter_by_query_pre

        scope.compact
      end

      protected
      attr_accessor :report, :scope

      def filter_by_query_pre
        scope_by_delta_processor
        scope_by_session
        scope_by_utf8
      end

      def scope_by_delta_processor
        self.scope << delta_processor.reset_query if delta_processor && !source.delta?
      end

      def scope_by_session
        if max_len = source.options[:group_concat_max_len]
          self.scope << "SET SESSION group_concat_max_len = #{max_len}"
        end
      end

      def scope_by_utf8
        self.scope += utf8_query_pre if source.options[:utf8?]
      end

      def method_missing(*args, &block)
        report.send *args, &block
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.4 lib/thinking_sphinx/active_record/sql_builder/query.rb