aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Wilk <josephwilk@joesniff.co.uk>2009-03-12 13:21:22 +0000
committerPratik Naik <pratiknaik@gmail.com>2009-06-21 19:51:32 +0100
commiteb30e4ca40370b416566f1bbaf0204bb379883e4 (patch)
tree16a0df573a65d4cfc922a07b54b4a44d902e81dc
parentb26c2c11ab47dbd4d1e26806d1e861edc7d697e0 (diff)
downloadrails-eb30e4ca40370b416566f1bbaf0204bb379883e4.tar.gz
rails-eb30e4ca40370b416566f1bbaf0204bb379883e4.tar.bz2
rails-eb30e4ca40370b416566f1bbaf0204bb379883e4.zip
Fixed a bug where create_table could not be called without a block [#2221 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb2
-rw-r--r--activerecord/test/cases/migration_test.rb7
2 files changed, 8 insertions, 1 deletions
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 ff63ea3a2e..f44cd0bd5a 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -101,7 +101,7 @@ module ActiveRecord
table_definition = TableDefinition.new(self)
table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name)) unless options[:id] == false
- yield table_definition
+ yield table_definition if block_given?
if options[:force] && table_exists?(table_name)
drop_table(table_name, options)
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 9ff95ae842..215b5a427a 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -293,6 +293,13 @@ if ActiveRecord::Base.connection.supports_migrations?
Person.connection.drop_table table_name rescue nil
end
+ def test_create_table_without_a_block
+ table_name = :testings
+ Person.connection.create_table table_name
+ ensure
+ Person.connection.drop_table table_name rescue nil
+ end
+
# Sybase, and SQLite3 will not allow you to add a NOT NULL
# column to a table without a default value.
unless current_adapter?(:SybaseAdapter, :SQLiteAdapter)