aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2008-05-07 15:11:55 +0100
committerPratik Naik <pratiknaik@gmail.com>2008-05-07 15:11:55 +0100
commitd9db5012879f0fc2a2e5f73aa3c6caddd49e48be (patch)
treee75fe378029db25e3d8fe6b4c8dc4aee89514891 /activerecord/lib
parentacf520457462d3987adbf540625c59e355e4d974 (diff)
parent0a21193dc660396fb993b06d1d3c168a9cd900a5 (diff)
downloadrails-d9db5012879f0fc2a2e5f73aa3c6caddd49e48be.tar.gz
rails-d9db5012879f0fc2a2e5f73aa3c6caddd49e48be.tar.bz2
rails-d9db5012879f0fc2a2e5f73aa3c6caddd49e48be.zip
Merge commit 'mainstream/master'
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/base.rb13
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb8
2 files changed, 7 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index c9db3ef7c6..755d353031 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1122,18 +1122,7 @@ module ActiveRecord #:nodoc:
# Indicates whether the table associated with this class exists
def table_exists?
- if connection.respond_to?(:tables)
- connection.tables.include? table_name
- else
- # if the connection adapter hasn't implemented tables, there are two crude tests that can be
- # used - see if getting column info raises an error, or if the number of columns returned is zero
- begin
- reset_column_information
- columns.size > 0
- rescue ActiveRecord::StatementInvalid
- false
- end
- end
+ connection.table_exists?(table_name)
end
# Returns an array of column objects for the table associated with this class.
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index b556516572..1594be40e2 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -20,6 +20,10 @@ module ActiveRecord
# def tables(name = nil) end
+ def table_exists?(table_name)
+ tables.include?(table_name.to_s)
+ end
+
# Returns an array of indexes for the given table.
# def indexes(table_name, name = nil) end
@@ -93,8 +97,8 @@ module ActiveRecord
yield table_definition
- if options[:force]
- drop_table(table_name, options) rescue nil
+ if options[:force] && table_exists?(table_name)
+ drop_table(table_name, options)
end
create_sql = "CREATE#{' TEMPORARY' if options[:temporary]} TABLE "