Skip to content

Commit

Permalink
MySQL: omit text/blob defaults from the schema instead of using an em…
Browse files Browse the repository at this point in the history
…pty string. Closes #10963.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8757 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Jan 30, 2008
1 parent 1ba5fc7 commit e59978a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MysqlColumn < Column #:nodoc:
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
Expand Down
6 changes: 1 addition & 5 deletions activerecord/test/cases/migration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -853,11 +853,7 @@ def test_create_table_with_binary_column
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
Expand Down
4 changes: 1 addition & 3 deletions activerecord/test/cases/schema_dumper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def test_schema_dump_with_string_ignored_table
assert_no_match %r{create_table "schema_info"}, output
end


def test_schema_dump_with_regexp_ignored_table
stream = StringIO.new

Expand All @@ -96,7 +95,6 @@ def test_schema_dump_with_regexp_ignored_table
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]
Expand All @@ -108,7 +106,7 @@ def test_schema_dump_illegal_ignored_table_value
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
Expand Down

1 comment on commit e59978a

@mdeiters
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boom!

Please sign in to comment.