Sha256: 7b8c3a9bdc84b1f6dd2ce039384e358ea6f4d404b18af42dfc6f256c6882732e

Contents?: true

Size: 929 Bytes

Versions: 5

Compression:

Stored size: 929 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_time_zone
        scope_by_session
        scope_by_utf8
      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 method_missing(*args, &block)
        report.send *args, &block
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinking-sphinx-3.1.4 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-3.1.3 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-3.1.2 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-3.1.1 lib/thinking_sphinx/active_record/sql_builder/query.rb
thinking-sphinx-3.1.0 lib/thinking_sphinx/active_record/sql_builder/query.rb