diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-05-09 12:42:48 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-05-09 12:42:48 +0100 |
commit | 8d2f6c16e381f5fff6d3f24f5c73a443577a1488 (patch) | |
tree | c79dbfcd8945652f7bf746c05043acf537affbd0 /activerecord/test | |
parent | f75a6fec2947ce23bd3ca4911d2d798415ccd355 (diff) | |
download | rails-8d2f6c16e381f5fff6d3f24f5c73a443577a1488.tar.gz rails-8d2f6c16e381f5fff6d3f24f5c73a443577a1488.tar.bz2 rails-8d2f6c16e381f5fff6d3f24f5c73a443577a1488.zip |
Revert "Revert "Add index length support for MySQL [#1852 state:open]""
This reverts commit 6626833db13a69786f9f6cd56b9f53c4017c3e39.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/active_schema_test_mysql.rb | 17 | ||||
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 8 |
2 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/test/cases/active_schema_test_mysql.rb b/activerecord/test/cases/active_schema_test_mysql.rb index 9aff538ce9..f4d123be15 100644 --- a/activerecord/test/cases/active_schema_test_mysql.rb +++ b/activerecord/test/cases/active_schema_test_mysql.rb @@ -15,6 +15,23 @@ class ActiveSchemaTest < ActiveRecord::TestCase end end + def test_add_index + expected = "CREATE INDEX `index_people_on_last_name` ON `people` (`last_name`)" + assert_equal expected, add_index(:people, :last_name, :length => nil) + + expected = "CREATE INDEX `index_people_on_last_name` ON `people` (`last_name`(10))" + assert_equal expected, add_index(:people, :last_name, :length => 10) + + expected = "CREATE INDEX `index_people_on_last_name_and_first_name` ON `people` (`last_name`(15), `first_name`(15))" + assert_equal expected, add_index(:people, [:last_name, :first_name], :length => 15) + + expected = "CREATE INDEX `index_people_on_last_name_and_first_name` ON `people` (`last_name`(15), `first_name`)" + assert_equal expected, add_index(:people, [:last_name, :first_name], :length => {:last_name => 15}) + + expected = "CREATE INDEX `index_people_on_last_name_and_first_name` ON `people` (`last_name`(15), `first_name`(10))" + assert_equal expected, add_index(:people, [:last_name, :first_name], :length => {:last_name => 15, :first_name => 10}) + end + def test_drop_table assert_equal "DROP TABLE `people`", drop_table(:people) end diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index a3d1ceaa1f..f67344445a 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -92,6 +92,14 @@ if ActiveRecord::Base.connection.supports_migrations? assert_nothing_raised { Person.connection.remove_index("people", "last_name_and_first_name") } assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } + assert_nothing_raised { Person.connection.add_index("people", ["last_name"], :length => 10) } + assert_nothing_raised { Person.connection.remove_index("people", "last_name") } + assert_nothing_raised { Person.connection.add_index("people", ["last_name"], :length => {:last_name => 10}) } + assert_nothing_raised { Person.connection.remove_index("people", ["last_name"]) } + assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"], :length => 10) } + assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } + assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"], :length => {:last_name => 10, :first_name => 20}) } + assert_nothing_raised { Person.connection.remove_index("people", ["last_name", "first_name"]) } end # quoting |