Sha256: 31ea1ac99174451d97541b02f827b187a20a7875be7e05b18add9457e306219f

Contents?: true

Size: 403 Bytes

Versions: 13

Compression:

Stored size: 403 Bytes

Contents

class << ActiveRecord::Base.connection
  IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SHOW FIELDS /]

  def execute_with_counting(sql, name = nil, &block)
    $query_count ||= 0
    $query_count  += 1 unless IGNORED_SQL.any? { |r| sql =~ r }
    execute_without_counting(sql, name, &block)
  end

  alias_method_chain :execute, :counting
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
arid_cache-1.3.6 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.3.5 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.3.4 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.3.3 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.3.2 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.3.1 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.3.0 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.2.0 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.1.1 test/lib/add_query_counting_to_active_record.rb
djmaze-arid_cache-1.1.0 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.1.0 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.0.4 test/lib/add_query_counting_to_active_record.rb
arid_cache-1.0.3 test/lib/add_query_counting_to_active_record.rb