diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-21 11:27:28 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-26 13:44:11 -0700 |
commit | 02128d628c4084eccd93c41db40f4d83db17f53c (patch) | |
tree | b6f9d3fbc37d1c75ab27aacd347f36e14be0f26a /activerecord | |
parent | 9d9aed433bd29eefb14807c02050cb8b88f15f0e (diff) | |
download | rails-02128d628c4084eccd93c41db40f4d83db17f53c.tar.gz rails-02128d628c4084eccd93c41db40f4d83db17f53c.tar.bz2 rails-02128d628c4084eccd93c41db40f4d83db17f53c.zip |
setting the authorized session clears the statement cache
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 1 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index e785cc6fea..4792f824cf 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -391,6 +391,7 @@ module ActiveRecord # Set the authorized user for this session def session_auth=(user) + clear_cache! exec "SET SESSION AUTHORIZATION #{user}" end diff --git a/activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb b/activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb index dc4f8fb955..881631fb19 100644 --- a/activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb +++ b/activerecord/test/cases/adapters/postgresql/schema_authorization_test.rb @@ -50,6 +50,17 @@ class SchemaAuthorizationTest < ActiveRecord::TestCase end end + def test_setting_auth_clears_stmt_cache + assert_nothing_raised do + set_session_auth + USERS.each do |u| + set_session_auth u + assert_equal u, @connection.exec("SELECT name FROM #{TABLE_NAME} WHERE id = $1", 'SQL', [[nil, 1]]).first['name'] + set_session_auth + end + end + end + def test_auth_with_bind assert_nothing_raised do set_session_auth |