Class: PG::Connection
- Inherits:
-
Object
- Object
- PG::Connection
- Defined in:
- lib/patches/sql_patches.rb
Instance Method Summary collapse
- #async_exec(*args, &blk) ⇒ Object
- #async_exec_without_profiling ⇒ Object
- #exec(*args, &blk) ⇒ Object (also: #query)
- #exec_prepared(*args, &blk) ⇒ Object
- #exec_prepared_without_profiling ⇒ Object
- #exec_without_profiling ⇒ Object
- #prepare(*args, &blk) ⇒ Object
- #prepare_without_profiling ⇒ Object
- #send_query_prepared(*args, &blk) ⇒ Object
- #send_query_prepared_without_profiling ⇒ Object
Instance Method Details
#async_exec(*args, &blk) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/patches/sql_patches.rb', line 153 def async_exec(*args,&blk) current = ::Rack::MiniProfiler.current return exec_without_profiling(*args,&blk) unless current 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 |
#async_exec_without_profiling ⇒ Object
93 |
# File 'lib/patches/sql_patches.rb', line 93 alias_method :async_exec_without_profiling, :async_exec |
#exec(*args, &blk) ⇒ Object Also known as: query
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/patches/sql_patches.rb', line 113 def exec(*args,&blk) current = ::Rack::MiniProfiler.current return exec_without_profiling(*args,&blk) unless current 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 |
#exec_prepared(*args, &blk) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File '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 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 ⇒ Object
94 |
# File 'lib/patches/sql_patches.rb', line 94 alias_method :exec_prepared_without_profiling, :exec_prepared |
#exec_without_profiling ⇒ Object
92 |
# File 'lib/patches/sql_patches.rb', line 92 alias_method :exec_without_profiling, :exec |
#prepare(*args, &blk) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File '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 prepare_without_profiling(*args,&blk) end |
#prepare_without_profiling ⇒ Object
96 |
# File 'lib/patches/sql_patches.rb', line 96 alias_method :prepare_without_profiling, :prepare |
#send_query_prepared(*args, &blk) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File '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 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 ⇒ Object
95 |
# File 'lib/patches/sql_patches.rb', line 95 alias_method :send_query_prepared_without_profiling, :send_query_prepared |