diff options
author | Cody Cutrer <cody@cutrer.us> | 2014-01-21 16:56:53 -0700 |
---|---|---|
committer | Steve Rice <steve@pagerduty.com> | 2014-03-25 21:29:14 -0700 |
commit | afa148a4f0ac5e2a446b5fe87881a130e8a24f3d (patch) | |
tree | f7c274ecbc55c280e48d1355fe217e0f6a9e1585 /activerecord/test/cases/adapters/mysql | |
parent | 470108b6e95a32e017ba3790d5701d8c8e91bf29 (diff) | |
download | rails-afa148a4f0ac5e2a446b5fe87881a130e8a24f3d.tar.gz rails-afa148a4f0ac5e2a446b5fe87881a130e8a24f3d.tar.bz2 rails-afa148a4f0ac5e2a446b5fe87881a130e8a24f3d.zip |
create indexes inline in CREATE TABLE for MySQL
This is important, because adding an index on a temporary table after
it has been created would commit the transaction
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test/cases/adapters/mysql')
-rw-r--r-- | activerecord/test/cases/adapters/mysql/active_schema_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/mysql/active_schema_test.rb b/activerecord/test/cases/adapters/mysql/active_schema_test.rb index e77138eb1d..072aa65000 100644 --- a/activerecord/test/cases/adapters/mysql/active_schema_test.rb +++ b/activerecord/test/cases/adapters/mysql/active_schema_test.rb @@ -116,6 +116,17 @@ class ActiveSchemaTest < ActiveRecord::TestCase end end + def test_indexes_in_create + begin + ActiveRecord::Base.connection.stubs(:index_name_exists?).returns(false) + expected = "CREATE TEMPORARY TABLE `temp` (INDEX `index_temp_on_zip` (`zip`)) ENGINE=InnoDB AS SELECT id, name, zip FROM a_really_complicated_query" + actual = ActiveRecord::Base.connection.create_table(:temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query") do |t| + t.index :zip + end + assert_equal expected, actual + end + end + private def with_real_execute ActiveRecord::Base.connection.singleton_class.class_eval do |