Sha256: 00645ab56d3abda39525cc55d94fa94a652ccd0fade3171de99f9f3e4db40456

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 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
        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_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

1 entries across 1 versions & 1 rubygems

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