Sha256: 60f9533a0ae88de5b1062c5a1202ec431753f7b126c1491b4d7a8714d96f5cb7

Contents?: true

Size: 1.17 KB

Versions: 17

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

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

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/active_record/sql_builder/query.rb