Permalink
Browse files

Merge commit 'refs/pull/2909/head' of https://github.com/rails/rails

…into rawr

* https://github.com/rails/rails:
  Postgresql adapter: added current_schema check for table_exists?
  Postgresql adapter: added current_schema check for table_exists?
  • Loading branch information...
2 parents 4a2e619 + 6a14b01 commit a6178c32e3282b71ed155ecdc35372d63a108d08 @tenderlove tenderlove committed Sep 7, 2011
@@ -717,7 +717,7 @@ def table_exists?(name)
SELECT COUNT(*)
FROM pg_tables
WHERE tablename = $1
- #{schema ? "AND schemaname = $2" : ''}
+ AND schemaname = #{schema ? "'#{schema}'" : "ANY (current_schemas(false))"}
SQL
end
@@ -68,7 +68,9 @@ def test_table_exists_wrong_schema
end
def test_table_exists_quoted_table
- assert(@connection.table_exists?('"things.table"'), "table should exist")
+ with_schema_search_path(SCHEMA_NAME) do
+ assert(@connection.table_exists?('"things.table"'), "table should exist")
+ end
end
def test_with_schema_prefixed_table_name

0 comments on commit a6178c3

Please sign in to comment.