Skip to content
This repository
Browse code

Revert "Don't carry default value when changing column for a binary t…

…ype on MySQL"

Broke mysql tests.

This reverts commit ddadcc7.

Conflicts:

	activerecord/test/cases/migration_test.rb

[#3234 state:open]
  • Loading branch information...
commit 9d99e610be0da6e4b682ebb8cc410cdca1ca633a 1 parent 99bcce7
Jeremy Kemper jeremy authored
6 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -506,7 +506,7 @@ def change_column_null(table_name, column_name, null, default = nil)
506 506 def change_column(table_name, column_name, type, options = {}) #:nodoc:
507 507 column = column_for(table_name, column_name)
508 508
509   - if has_default?(type) && !options_include_default?(options)
  509 + unless options_include_default?(options)
510 510 options[:default] = column.default
511 511 end
512 512
@@ -655,10 +655,6 @@ def column_for(table_name, column_name)
655 655 end
656 656 column
657 657 end
658   -
659   - def has_default?(sql_type)
660   - sql_type =~ :binary || sql_type == :text #mysql forbids defaults on blob and text columns
661   - end
662 658 end
663 659 end
664 660 end
12 activerecord/test/cases/migration_test.rb
@@ -857,18 +857,6 @@ def test_change_column_default
857 857 assert_equal "Tester", Person.new.first_name
858 858 end
859 859
860   - unless current_adapter?(:PostgreSQLAdapter)
861   - def test_change_column_type_default_should_change
862   - old_columns = Person.connection.columns(Person.table_name, "#{name} Columns")
863   - assert !old_columns.find { |c| c.name == 'data' }
864   -
865   - assert_nothing_raised do
866   - Person.connection.add_column "people", "data", :string, :default => ''
867   - Person.connection.change_column "people", "data", :binary
868   - end
869   - end
870   - end
871   -
872 860 def test_change_column_quotes_column_names
873 861 Person.connection.create_table :testings do |t|
874 862 t.column :select, :string

0 comments on commit 9d99e61

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