diff options
author | Victor Costan <costan@gmail.com> | 2012-10-16 05:53:18 -0400 |
---|---|---|
committer | Victor Costan <costan@gmail.com> | 2012-10-27 13:41:27 -0400 |
commit | 5d30e443908558713cff16cdad4b09e203c8fae8 (patch) | |
tree | 071dcdd7622515bc8c2556e36f2745e5d22a7fe2 /activerecord/test/cases | |
parent | 028f29dc91cad17ae0634e0973f7ff1b43435466 (diff) | |
download | rails-5d30e443908558713cff16cdad4b09e203c8fae8.tar.gz rails-5d30e443908558713cff16cdad4b09e203c8fae8.tar.bz2 rails-5d30e443908558713cff16cdad4b09e203c8fae8.zip |
Use the MySQL varbinary type when appropriate in migrations.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/adapters/mysql/sql_types_test.rb | 14 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/mysql2/sql_types_test.rb | 14 | ||||
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 6 |
3 files changed, 34 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql/sql_types_test.rb b/activerecord/test/cases/adapters/mysql/sql_types_test.rb new file mode 100644 index 0000000000..1ddb1b91c9 --- /dev/null +++ b/activerecord/test/cases/adapters/mysql/sql_types_test.rb @@ -0,0 +1,14 @@ +require "cases/helper" + +class SqlTypesTest < ActiveRecord::TestCase + def test_binary_types + assert_equal 'varbinary(64)', type_to_sql(:binary, 64) + assert_equal 'varbinary(4095)', type_to_sql(:binary, 4095) + assert_equal 'blob(4096)', type_to_sql(:binary, 4096) + assert_equal 'blob', type_to_sql(:binary) + end + + def type_to_sql(*args) + ActiveRecord::Base.connection.type_to_sql(*args) + end +end diff --git a/activerecord/test/cases/adapters/mysql2/sql_types_test.rb b/activerecord/test/cases/adapters/mysql2/sql_types_test.rb new file mode 100644 index 0000000000..1ddb1b91c9 --- /dev/null +++ b/activerecord/test/cases/adapters/mysql2/sql_types_test.rb @@ -0,0 +1,14 @@ +require "cases/helper" + +class SqlTypesTest < ActiveRecord::TestCase + def test_binary_types + assert_equal 'varbinary(64)', type_to_sql(:binary, 64) + assert_equal 'varbinary(4095)', type_to_sql(:binary, 4095) + assert_equal 'blob(4096)', type_to_sql(:binary, 4096) + assert_equal 'blob', type_to_sql(:binary) + end + + def type_to_sql(*args) + ActiveRecord::Base.connection.type_to_sql(*args) + end +end diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index 5f13124e5b..7ff0044bd4 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -203,6 +203,12 @@ class SchemaDumperTest < ActiveRecord::TestCase assert_match %r{t.text\s+"body",\s+null: false$}, output end + def test_schema_dump_includes_length_for_mysql_binary_fields + output = standard_dump + assert_match %r{t.binary\s+"var_binary",\s+limit: 255$}, output + assert_match %r{t.binary\s+"var_binary_large",\s+limit: 4095$}, output + end + def test_schema_dump_includes_length_for_mysql_blob_and_text_fields output = standard_dump assert_match %r{t.binary\s+"tiny_blob",\s+limit: 255$}, output |