Sha256: c7aba50c2561ab5a14408ea6cc4d92ce68f21d2eab296888af010b589d57e6db

Contents?: true

Size: 1.14 KB

Versions: 4

Compression:

Stored size: 1.14 KB

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_time_zone
        scope_by_delta_processor
        scope_by_session
        scope_by_utf8
      end

      def scope_by_delta_processor
        return unless delta_processor && !source.delta?

        self.scope << delta_processor.reset_query
      end

      def scope_by_session
        return unless max_len = source.options[:group_concat_max_len]

        self.scope << "SET SESSION group_concat_max_len = #{max_len}"
      end

      def scope_by_time_zone
        return if config.settings['skip_time_zone']

        self.scope += time_zone_query_pre
      end

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-3.4.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-3.3.0 lib/thinking_sphinx/active_record/sql_builder/query.rb