Skip to content
Browse files

In PostgreSQLAdapter, switch tables query to use current_schemas func…

…tion [#918 state:resolved]

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
1 parent 56a86c2 commit afb786ad8a27ae593790a5788441a9083a516195 @krisselden krisselden committed with wycats Mar 26, 2010
View
4 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -651,14 +651,12 @@ def drop_database(name) #:nodoc:
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
View
9 activerecord/test/cases/schema_authorization_test_postgresql.rb
@@ -66,6 +66,15 @@ def test_sequence_schema_caching
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

0 comments on commit afb786a

Please sign in to comment.
Something went wrong with that request. Please try again.