aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-04-11 14:48:49 -0700
committerwycats <wycats@gmail.com>2010-04-11 14:53:24 -0700
commitecf039fc05ac32b7a8cbd005dd4723d7eadc61c0 (patch)
tree209983e4bc54aae7ee1067fe403a670e40bb0bcb /activerecord/test/cases
parent803df08d896b82ae3e86c9c1e3c2ea4b6826ef70 (diff)
downloadrails-ecf039fc05ac32b7a8cbd005dd4723d7eadc61c0.tar.gz
rails-ecf039fc05ac32b7a8cbd005dd4723d7eadc61c0.tar.bz2
rails-ecf039fc05ac32b7a8cbd005dd4723d7eadc61c0.zip
mode postgresql adapters table_exists? method take the schema in to account. [#4341 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/schema_test_postgresql.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/schema_test_postgresql.rb b/activerecord/test/cases/schema_test_postgresql.rb
index a294848fa3..3ed73786a7 100644
--- a/activerecord/test/cases/schema_test_postgresql.rb
+++ b/activerecord/test/cases/schema_test_postgresql.rb
@@ -52,6 +52,21 @@ class SchemaTest < ActiveRecord::TestCase
@connection.execute "DROP SCHEMA #{SCHEMA_NAME} CASCADE"
end
+ def test_table_exists?
+ [Thing1, Thing2, Thing3, Thing4].each do |klass|
+ name = klass.table_name
+ assert @connection.table_exists?(name), "'#{name}' table should exist"
+ end
+ end
+
+ def test_table_exists_wrong_schema
+ assert(!@connection.table_exists?("foo.things"), "table should not exist")
+ end
+
+ def test_table_exists_quoted_table
+ assert(@connection.table_exists?('"things.table"'), "table should exist")
+ end
+
def test_with_schema_prefixed_table_name
assert_nothing_raised do
assert_equal COLUMNS, columns("#{SCHEMA_NAME}.#{TABLE_NAME}")