Skip to content
This repository
Browse code

Fixed a bug where create_table could not be called without a block [#…

…2221 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
commit eb30e4ca40370b416566f1bbaf0204bb379883e4 1 parent b26c2c1
authored lifo committed
2  activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -101,7 +101,7 @@ def create_table(table_name, options = {})
101 101
         table_definition = TableDefinition.new(self)
102 102
         table_definition.primary_key(options[:primary_key] || Base.get_primary_key(table_name)) unless options[:id] == false
103 103
 
104  
-        yield table_definition
  104
+        yield table_definition if block_given?
105 105
 
106 106
         if options[:force] && table_exists?(table_name)
107 107
           drop_table(table_name, options)
7  activerecord/test/cases/migration_test.rb
@@ -293,6 +293,13 @@ def test_create_table_with_timestamps_should_create_datetime_columns_with_option
293 293
       Person.connection.drop_table table_name rescue nil
294 294
     end
295 295
 
  296
+    def test_create_table_without_a_block
  297
+      table_name = :testings
  298
+      Person.connection.create_table table_name
  299
+    ensure
  300
+      Person.connection.drop_table table_name rescue nil
  301
+    end
  302
+
296 303
     # Sybase, and SQLite3 will not allow you to add a NOT NULL
297 304
     # column to a table without a default value.
298 305
     unless current_adapter?(:SybaseAdapter, :SQLiteAdapter)

0 notes on commit eb30e4c

Please sign in to comment.
Something went wrong with that request. Please try again.