From eb30e4ca40370b416566f1bbaf0204bb379883e4 Mon Sep 17 00:00:00 2001 From: Joseph Wilk Date: Thu, 12 Mar 2009 13:21:22 +0000 Subject: Fixed a bug where create_table could not be called without a block [#2221 state:resolved] Signed-off-by: Pratik Naik --- .../connection_adapters/abstract/schema_statements.rb | 2 +- activerecord/test/cases/migration_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3