Sha256: dd1cf1013d9bf6621b667d5e6c726407d91294d8c13775808109529cf9bcfb9d

Contents?: true

Size: 861 Bytes

Versions: 12

Compression:

Stored size: 861 Bytes

Contents

module Cucumber
  module ThinkingSphinx
    module SqlLogger
      IGNORED_SQL = [
        /^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/,
        /^SELECT @@ROWCOUNT/, /^SHOW FIELDS/
      ]

      if ActiveRecord::VERSION::STRING.to_f > 3.0
        def log(sql, name = 'SQL', binds = [])
          $queries_executed ||= []
          $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
          super sql, name, binds
        end
      else
        def self.included(base)
          base.send :alias_method_chain, :execute, :query_record
        end

        def execute_with_query_record(sql, name = 'SQL', &block)
          $queries_executed ||= []
          $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
          execute_without_query_record(sql, name, &block)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
friendlyfashion-thinking-sphinx-2.0.14.4 lib/cucumber/thinking_sphinx/sql_logger.rb
friendlyfashion-thinking-sphinx-2.0.14.3 lib/cucumber/thinking_sphinx/sql_logger.rb
thinking-sphinx-2.1.0 lib/cucumber/thinking_sphinx/sql_logger.rb
friendlyfashion-thinking-sphinx-2.0.14.2 lib/cucumber/thinking_sphinx/sql_logger.rb
friendlyfashion-thinking-sphinx-2.0.14.1 lib/cucumber/thinking_sphinx/sql_logger.rb
thinking-sphinx-2.0.14 lib/cucumber/thinking_sphinx/sql_logger.rb
friendlyfashion-thinking-sphinx-2.0.13.3 lib/cucumber/thinking_sphinx/sql_logger.rb
friendlyfashion-thinking-sphinx-2.0.13.2 lib/cucumber/thinking_sphinx/sql_logger.rb
friendlyfashion-thinking-sphinx-2.0.13.1 lib/cucumber/thinking_sphinx/sql_logger.rb
friendlyfashion-thinking-sphinx-2.0.13 lib/cucumber/thinking_sphinx/sql_logger.rb
thinking-sphinx-2.0.13 lib/cucumber/thinking_sphinx/sql_logger.rb
thinking-sphinx-2.0.12 lib/cucumber/thinking_sphinx/sql_logger.rb