Permalink
Browse files

Refactored remove_column

  • Loading branch information...
1 parent c0a7038 commit 6d6907e40d2ff5b08560ee24fc192a72acfa0347 @ebeigarts ebeigarts committed Nov 21, 2011
@@ -408,7 +408,7 @@ def change_default(column_name, default)
# t.remove(:qualification)
# t.remove(:qualification, :experience)
def remove(*column_names)
- @base.remove_column(@table_name, column_names)
+ @base.remove_column(@table_name, *column_names)
end
# Removes the given index from the table.
@@ -618,8 +618,6 @@ def index_name_for_remove(table_name, options = {})
end
def columns_for_remove(table_name, *column_names)
- column_names = column_names.flatten
-
raise ArgumentError.new("You must specify at least one column name. Example: remove_column(:people, :first_name)") if column_names.blank?
column_names.map {|column_name| quote_column_name(column_name) }
end
@@ -446,7 +446,7 @@ def add_column(table_name, column_name, type, options = {}) #:nodoc:
def remove_column(table_name, *column_names) #:nodoc:
raise ArgumentError.new("You must specify at least one column name. Example: remove_column(:people, :first_name)") if column_names.empty?
- column_names.flatten.each do |column_name|
+ column_names.each do |column_name|
alter_table(table_name) do |definition|
definition.columns.delete(definition[column_name])
end
@@ -588,14 +588,14 @@ def test_change_default_changes_column
def test_remove_drops_single_column
with_change_table do |t|
- @connection.expects(:remove_column).with(:delete_me, [:bar])
+ @connection.expects(:remove_column).with(:delete_me, :bar)
t.remove :bar
end
end
def test_remove_drops_multiple_columns
with_change_table do |t|
- @connection.expects(:remove_column).with(:delete_me, [:bar, :baz])
+ @connection.expects(:remove_column).with(:delete_me, :bar, :baz)
t.remove :bar, :baz
end
end

0 comments on commit 6d6907e

Please sign in to comment.