Skip to content

Commit

Permalink
Merge commit 'refs/pull/2909/head' of https://github.com/rails/rails
Browse files Browse the repository at this point in the history
…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
tenderlove committed Sep 7, 2011
2 parents 4a2e619 + 6a14b01 commit a6178c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion activerecord/test/cases/adapters/postgresql/schema_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit a6178c3

Please sign in to comment.