diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-08-14 06:17:20 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-08-19 12:11:26 +0900 |
commit | 99cb16a2babfb10b8c2bc3270a38fcb3ca92bb09 (patch) | |
tree | b7132e8de07a5bafbb5fd432fb38047408fd8b05 /activerecord/test/cases/column_definition_test.rb | |
parent | 28aaf77bb07af5e0108ff986e192e71da6d25078 (diff) | |
download | rails-99cb16a2babfb10b8c2bc3270a38fcb3ca92bb09.tar.gz rails-99cb16a2babfb10b8c2bc3270a38fcb3ca92bb09.tar.bz2 rails-99cb16a2babfb10b8c2bc3270a38fcb3ca92bb09.zip |
Remove text default treated as an empty string in non-strict mode
Strict mode controls how MySQL handles invalid or missing values in
data-change statements such as INSERT or UPDATE. If strict mode is not
in effect, MySQL inserts adjusted values for invalid or missing values
and produces warnings.
```ruby
def test_mysql_not_null_defaults_non_strict
using_strict(false) do
with_mysql_not_null_table do |klass|
record = klass.new
assert_nil record.non_null_integer
assert_nil record.non_null_string
assert_nil record.non_null_text
assert_nil record.non_null_blob
record.save!
record.reload
assert_equal 0, record.non_null_integer
assert_equal "", record.non_null_string
assert_equal "", record.non_null_text
assert_equal "", record.non_null_blob
end
end
end
```
It is inconsistent with other types that only text/blob defaults treated
as an empty string. This commit fixes the inconsistency.
Diffstat (limited to 'activerecord/test/cases/column_definition_test.rb')
-rw-r--r-- | activerecord/test/cases/column_definition_test.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/test/cases/column_definition_test.rb b/activerecord/test/cases/column_definition_test.rb index 989beaa5c8..a65bb89052 100644 --- a/activerecord/test/cases/column_definition_test.rb +++ b/activerecord/test/cases/column_definition_test.rb @@ -60,14 +60,13 @@ module ActiveRecord end def test_should_not_set_default_for_blob_and_text_data_types - text_type = MySQL::TypeMetadata.new( - SqlTypeMetadata.new(type: :text)) + text_type = MySQL::TypeMetadata.new(SqlTypeMetadata.new(type: :text)) text_column = MySQL::Column.new("title", nil, text_type) - assert_equal nil, text_column.default + assert_nil text_column.default not_null_text_column = MySQL::Column.new("title", nil, text_type, false) - assert_equal "", not_null_text_column.default + assert_nil not_null_text_column.default end def test_has_default_should_return_false_for_blob_and_text_data_types |