diff options
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/connection_test.rb | 10 | ||||
-rw-r--r-- | activerecord/test/cases/helper.rb | 3 |
2 files changed, 13 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 diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 6bcbf9c3cc..739e2b2f19 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -121,12 +121,15 @@ end class SQLSubscriber attr_reader :logged + attr_reader :payloads def initialize @logged = [] + @payloads = [] end def start(name, id, payload) + @payloads << payload @logged << [payload[:sql], payload[:name], payload[:binds]] end |