aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2010-05-18 11:02:39 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2010-05-18 11:02:39 -0700
commit223d6415d045e670610603665c21e93b06a01db7 (patch)
treecbbcf7d16d3a19d05e9cacef9983b43ea489df19
parent3809c80cd55ac2838f050346800889b6f8e041ef (diff)
downloadrails-223d6415d045e670610603665c21e93b06a01db7.tar.gz
rails-223d6415d045e670610603665c21e93b06a01db7.tar.bz2
rails-223d6415d045e670610603665c21e93b06a01db7.zip
Revert "Don't carry default value when changing column for a binary type on MySQL"
Broke mysql tests. This reverts commit edec1afe25014749f0e2df86d27477b45586a9e3. Conflicts: activerecord/test/cases/migration_test.rb [#3234 state:open]
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql_adapter.rb6
-rw-r--r--activerecord/test/cases/migration_test.rb12
2 files changed, 1 insertions, 17 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index e12924e63f..ec25bbf18e 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -513,7 +513,7 @@ module ActiveRecord
def change_column(table_name, column_name, type, options = {}) #:nodoc:
column = column_for(table_name, column_name)
- if has_default?(type) && !options_include_default?(options)
+ unless options_include_default?(options)
options[:default] = column.default
end
@@ -675,10 +675,6 @@ module ActiveRecord
end
column
end
-
- def has_default?(sql_type)
- sql_type =~ :binary || sql_type == :text #mysql forbids defaults on blob and text columns
- end
end
end
end
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 851daa69a5..692e4b207f 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -894,18 +894,6 @@ if ActiveRecord::Base.connection.supports_migrations?
assert_equal "Tester", Person.new.first_name
end
- unless current_adapter?(:PostgreSQLAdapter)
- def test_change_column_type_default_should_change
- old_columns = Person.connection.columns(Person.table_name, "#{name} Columns")
- assert !old_columns.find { |c| c.name == 'data' }
-
- assert_nothing_raised do
- Person.connection.add_column "people", "data", :string, :default => ''
- Person.connection.change_column "people", "data", :binary
- end
- end
- end
-
def test_change_column_quotes_column_names
Person.connection.create_table :testings do |t|
t.column :select, :string