diff options
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 1 | ||||
-rw-r--r-- | activerecord/test/cases/migration/columns_test.rb | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index dfb4953cbd..897b50a158 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -229,6 +229,7 @@ module ActiveRecord column_types.each do |column_type| module_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{column_type}(*names, **options) + raise ArgumentError, "missing column name(s) for #{column_type}" if names.empty? names.each { |name| column(name, :#{column_type}, options) } end RUBY diff --git a/activerecord/test/cases/migration/columns_test.rb b/activerecord/test/cases/migration/columns_test.rb index cedd9c44e3..e5dfdf1655 100644 --- a/activerecord/test/cases/migration/columns_test.rb +++ b/activerecord/test/cases/migration/columns_test.rb @@ -318,6 +318,15 @@ module ActiveRecord ensure connection.drop_table(:my_table) rescue nil end + + def test_add_column_without_column_name + e = assert_raise ArgumentError do + connection.create_table "my_table", force: true do |t| + t.timestamp + end + end + assert e.message.include?("timestamp") + end end end end |