Class: Mysql2::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/patches/sql_patches.rb

Instance Method Summary collapse

Instance Method Details

#query(*args, &blk) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/patches/sql_patches.rb', line 43

def query(*args,&blk)
  current = ::Rack::MiniProfiler.current
  return query_without_profiling(*args,&blk) unless current

  start = Time.now
  result = query_without_profiling(*args,&blk)
  elapsed_time = ((Time.now - start).to_f * 1000).round(1)
  result.instance_variable_set("@miniprofiler_sql_id", ::Rack::MiniProfiler.record_sql(args[0], elapsed_time))

  result

end

#query_without_profilingObject



42
# File 'lib/patches/sql_patches.rb', line 42

alias_method :query_without_profiling, :query