diff options
author | Cody Cutrer <cody@instructure.com> | 2013-12-13 15:20:03 -0700 |
---|---|---|
committer | Cody Cutrer <cody@cutrer.us> | 2013-12-14 07:07:10 -0700 |
commit | 75a2e4a8dff8c01dad913048d3676b993a8e23a2 (patch) | |
tree | 1cea1a48cc5d501f5146c392d5fa8d05c71b8637 /activerecord/test/cases/migration_test.rb | |
parent | 068580d4456e881e568de4a4d20a401e87b6c9e1 (diff) | |
download | rails-75a2e4a8dff8c01dad913048d3676b993a8e23a2.tar.gz rails-75a2e4a8dff8c01dad913048d3676b993a8e23a2.tar.bz2 rails-75a2e4a8dff8c01dad913048d3676b993a8e23a2.zip |
support creating temporary tables from queries
also override drop_table in AbstractMySQLAdapter to properly drop
temporary tables without committing the transaction
Diffstat (limited to 'activerecord/test/cases/migration_test.rb')
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 519045095d..ebcc778b8b 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -443,6 +443,32 @@ class MigrationTest < ActiveRecord::TestCase Person.connection.drop_table :binary_testings rescue nil end + def test_create_table_with_query + Person.connection.drop_table :table_from_query_testings rescue nil + Person.connection.create_table(:person, force: true) + + Person.connection.create_table :table_from_query_testings, as: "SELECT id FROM person" + + columns = Person.connection.columns(:table_from_query_testings) + assert_equal 1, columns.length + assert_equal "id", columns.first.name + + Person.connection.drop_table :table_from_query_testings rescue nil + end + + def test_create_table_with_query_from_relation + Person.connection.drop_table :table_from_query_testings rescue nil + Person.connection.create_table(:person, force: true) + + Person.connection.create_table :table_from_query_testings, as: Person.select(:id) + + columns = Person.connection.columns(:table_from_query_testings) + assert_equal 1, columns.length + assert_equal "id", columns.first.name + + Person.connection.drop_table :table_from_query_testings rescue nil + end + if current_adapter? :OracleAdapter def test_create_table_with_custom_sequence_name # table name is 29 chars, the standard sequence name will |