diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 4 |
4 files changed, 5 insertions, 9 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index ef21f5d1d3..5b232f93a2 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* MySQL: omit text/blob defaults from the schema instead of using an empty string. #10963 [mdeiters] + * belongs_to supports :dependent => :destroy and :delete. #10592 [Jonathan Viney] * Introduce preload query strategy for eager :includes. #9640 [Frederick Cheung, Aleksey Kondratenko] diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 04869bd925..08d29419a5 100755 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -94,7 +94,7 @@ module ActiveRecord def extract_default(default) if type == :binary || type == :text if default.blank? - default + nil else raise ArgumentError, "#{type} columns cannot have a default value: #{default.inspect}" end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 59cb6c1fe7..3ce61cd7a1 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -853,11 +853,7 @@ if ActiveRecord::Base.connection.supports_migrations? columns = Person.connection.columns(:binary_testings) data_column = columns.detect { |c| c.name == "data" } - if current_adapter?(:MysqlAdapter) - assert_equal '', data_column.default - else - assert_nil data_column.default - end + assert_nil data_column.default Person.connection.drop_table :binary_testings rescue nil end diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index 08f4a9b421..8413fce3fa 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -84,7 +84,6 @@ if ActiveRecord::Base.connection.respond_to?(:tables) assert_no_match %r{create_table "schema_info"}, output end - def test_schema_dump_with_regexp_ignored_table stream = StringIO.new @@ -96,7 +95,6 @@ if ActiveRecord::Base.connection.respond_to?(:tables) assert_no_match %r{create_table "schema_info"}, output end - def test_schema_dump_illegal_ignored_table_value stream = StringIO.new ActiveRecord::SchemaDumper.ignore_tables = [5] @@ -108,7 +106,7 @@ if ActiveRecord::Base.connection.respond_to?(:tables) if current_adapter?(:MysqlAdapter) def test_schema_dump_should_not_add_default_value_for_mysql_text_field output = standard_dump - assert_match %r{t.text\s+"body",\s+:default => "",\s+:null => false$}, output + assert_match %r{t.text\s+"body",\s+:null => false$}, output end def test_mysql_schema_dump_should_honor_nonstandard_primary_keys |