diff options
author | Elomar França <elomar@maisweb.org> | 2009-09-27 13:42:13 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-05-16 10:45:26 +0200 |
commit | edec1afe25014749f0e2df86d27477b45586a9e3 (patch) | |
tree | c644f7fd5170452c51c772393e7c406b402d71bc /activerecord/lib | |
parent | 3afdfc35e8aec7e6379e093dd1278cb3de54f21b (diff) | |
download | rails-edec1afe25014749f0e2df86d27477b45586a9e3.tar.gz rails-edec1afe25014749f0e2df86d27477b45586a9e3.tar.bz2 rails-edec1afe25014749f0e2df86d27477b45586a9e3.zip |
Don't carry default value when changing column for a binary type on MySQL [#3234 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index ec25bbf18e..e12924e63f 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) - unless options_include_default?(options) + if has_default?(type) && !options_include_default?(options) options[:default] = column.default end @@ -675,6 +675,10 @@ 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 |