diff options
author | Kris Selden <kris.selden@gmail.com> | 2010-03-26 15:21:55 -0700 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-03-26 17:18:33 -0700 |
commit | afb786ad8a27ae593790a5788441a9083a516195 (patch) | |
tree | d7bbd242d75d8a9aca1ff3bb0ee2b45f4abaffaf /activerecord | |
parent | 56a86c2191e159448bd2644f105f629c34c85c48 (diff) | |
download | rails-afb786ad8a27ae593790a5788441a9083a516195.tar.gz rails-afb786ad8a27ae593790a5788441a9083a516195.tar.bz2 rails-afb786ad8a27ae593790a5788441a9083a516195.zip |
In PostgreSQLAdapter, switch tables query to use current_schemas function [#918 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/schema_authorization_test_postgresql.rb | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index b3ce8c79dd..c9a5f00dfd 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -651,14 +651,12 @@ module ActiveRecord end end - # Returns the list of all tables in the schema search path or a specified schema. def tables(name = nil) - schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',') query(<<-SQL, name).map { |row| row[0] } SELECT tablename FROM pg_tables - WHERE schemaname IN (#{schemas}) + WHERE schemaname = ANY (current_schemas(false)) SQL end diff --git a/activerecord/test/cases/schema_authorization_test_postgresql.rb b/activerecord/test/cases/schema_authorization_test_postgresql.rb index ba7754513d..2860f1ad48 100644 --- a/activerecord/test/cases/schema_authorization_test_postgresql.rb +++ b/activerecord/test/cases/schema_authorization_test_postgresql.rb @@ -66,6 +66,15 @@ class SchemaAuthorizationTest < ActiveRecord::TestCase end end end + + def test_tables_in_current_schemas + assert !@connection.tables.include?(TABLE_NAME) + USERS.each do |u| + set_session_auth u + assert @connection.tables.include?(TABLE_NAME) + set_session_auth + end + end private def set_session_auth auth = nil |