class PG::Connection

Public Instance Methods

async_exec(*args,&blk) click to toggle source
# File Ruby/lib/patches/sql_patches.rb, line 153
def async_exec(*args,&blk)
  current = ::Rack::MiniProfiler.current
  return exec_without_profiling(*args,&blk) unless current && current.measure

  start = Time.now
  result = exec_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
Also aliased as: async_exec_without_profiling
async_exec_without_profiling(*args,&blk) click to toggle source
Alias for: async_exec
exec(*args,&blk) click to toggle source
# File Ruby/lib/patches/sql_patches.rb, line 113
def exec(*args,&blk)
  current = ::Rack::MiniProfiler.current
  return exec_without_profiling(*args,&blk) unless current && current.measure

  start = Time.now
  result = exec_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
Also aliased as: exec_without_profiling, query
exec_prepared(*args,&blk) click to toggle source
# File Ruby/lib/patches/sql_patches.rb, line 125
def exec_prepared(*args,&blk)
  current = ::Rack::MiniProfiler.current
  return exec_prepared_without_profiling(*args,&blk) unless current && current.measure

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

  result
end
exec_prepared_without_profiling(*args,&blk) click to toggle source
Alias for: exec_prepared
exec_without_profiling(*args,&blk) click to toggle source
Alias for: exec
prepare(*args,&blk) click to toggle source
# File Ruby/lib/patches/sql_patches.rb, line 98
def prepare(*args,&blk)
  # we have no choice but to do this here,
  # if we do the check for profiling first, our cache may miss critical stuff

  @prepare_map ||= {}
  @prepare_map[args[0]] = args[1]
  # dont leak more than 10k ever
  @prepare_map = {} if @prepare_map.length > 1000

  current = ::Rack::MiniProfiler.current
  return prepare_without_profiling(*args,&blk) unless current && current.measure

  prepare_without_profiling(*args,&blk)
end
Also aliased as: prepare_without_profiling
prepare_without_profiling(*args,&blk) click to toggle source
Alias for: prepare
query(*args,&blk) click to toggle source
Alias for: exec
send_query_prepared(*args,&blk) click to toggle source
# File Ruby/lib/patches/sql_patches.rb, line 139
def send_query_prepared(*args,&blk)
  current = ::Rack::MiniProfiler.current
  return send_query_prepared_without_profiling(*args,&blk) unless current && current.measure

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

  result
end
send_query_prepared_without_profiling(*args,&blk) click to toggle source
Alias for: send_query_prepared