aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/connection_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-04 16:51:35 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-04 16:51:35 -0700
commit2ae9166d8fef242e3b0d52af0c8c79d86a80268e (patch)
treebe5adbbf0ba449a7d99ed2913a640f2ff4da1d40 /activerecord/test/cases/adapters/postgresql/connection_test.rb
parent98e001641ff0f859349cd60d270fec972edc16de (diff)
downloadrails-2ae9166d8fef242e3b0d52af0c8c79d86a80268e.tar.gz
rails-2ae9166d8fef242e3b0d52af0c8c79d86a80268e.tar.bz2
rails-2ae9166d8fef242e3b0d52af0c8c79d86a80268e.zip
log the statement name along with the SQL
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/connection_test.rb')
-rw-r--r--activerecord/test/cases/adapters/postgresql/connection_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/connection_test.rb b/activerecord/test/cases/adapters/postgresql/connection_test.rb
index 59d95d1293..81aa977c59 100644
--- a/activerecord/test/cases/adapters/postgresql/connection_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/connection_test.rb
@@ -81,6 +81,16 @@ module ActiveRecord
assert_equal 'SCHEMA', @subscriber.logged[0][1]
end
+ def test_statement_key_is_logged
+ bindval = 1
+ @connection.exec_query('SELECT $1::integer', 'SQL', [[nil, bindval]])
+ name = @subscriber.payloads.last[:statement_name]
+ assert name
+ res = @connection.exec_query("EXPLAIN (FORMAT JSON) EXECUTE #{name}(#{bindval})")
+ plan = res.column_types['QUERY PLAN'].type_cast res.rows.first.first
+ assert_operator plan.length, :>, 0
+ end
+
# Must have with_manual_interventions set to true for this
# test to run.
# When prompted, restart the PostgreSQL server with the