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
158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/patches/sql_patches.rb', line 158 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) record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time) result.instance_variable_set("@miniprofiler_sql_id", record) if result result end |
#async_exec_without_profiling ⇒ Object
94 |
# File 'lib/patches/sql_patches.rb', line 94 alias_method :async_exec_without_profiling, :async_exec |
#exec(*args, &blk) ⇒ Object Also known as: query
114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/patches/sql_patches.rb', line 114 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) record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time) result.instance_variable_set("@miniprofiler_sql_id", record) if result result end |
#exec_prepared(*args, &blk) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/patches/sql_patches.rb', line 127 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 record = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time) result.instance_variable_set("@miniprofiler_sql_id", record) if result result end |
#exec_prepared_without_profiling ⇒ Object
95 |
# File 'lib/patches/sql_patches.rb', line 95 alias_method :exec_prepared_without_profiling, :exec_prepared |
#exec_without_profiling ⇒ Object
93 |
# File 'lib/patches/sql_patches.rb', line 93 alias_method :exec_without_profiling, :exec |
#prepare(*args, &blk) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/patches/sql_patches.rb', line 99 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 |
#prepare_without_profiling ⇒ Object
97 |
# File 'lib/patches/sql_patches.rb', line 97 alias_method :prepare_without_profiling, :prepare |
#send_query_prepared(*args, &blk) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/patches/sql_patches.rb', line 142 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 record = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time) result.instance_variable_set("@miniprofiler_sql_id", record) if result result end |
#send_query_prepared_without_profiling ⇒ Object
96 |
# File 'lib/patches/sql_patches.rb', line 96 alias_method :send_query_prepared_without_profiling, :send_query_prepared |