aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-06-17 09:58:12 +0930
committerGitHub <noreply@github.com>2017-06-17 09:58:12 +0930
commita1c8b4612373527333e59baca6d5fcf5598dd6eb (patch)
tree1fee3e832a74dc66f5c719449a1e004619030c8f /activerecord/test/cases
parentc295296de3c07e48557b34062adb980ef5b1ec17 (diff)
parent7dbe62006da2576770babe92234467574834f305 (diff)
downloadrails-a1c8b4612373527333e59baca6d5fcf5598dd6eb.tar.gz
rails-a1c8b4612373527333e59baca6d5fcf5598dd6eb.tar.bz2
rails-a1c8b4612373527333e59baca6d5fcf5598dd6eb.zip
Merge pull request #29431 from kamipo/fix_create_table_with_query_from_relation
Fix `create_table` with query from relation
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/migration_test.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 57f94950f9..3a49a41580 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -502,11 +502,10 @@ class MigrationTest < ActiveRecord::TestCase
unless mysql_enforcing_gtid_consistency?
def test_create_table_with_query
- Person.connection.create_table(:person, force: true)
-
- Person.connection.create_table :table_from_query_testings, as: "SELECT id FROM person"
+ Person.connection.create_table :table_from_query_testings, as: "SELECT id FROM people WHERE id = 1"
columns = Person.connection.columns(:table_from_query_testings)
+ assert_equal [1], Person.connection.select_values("SELECT * FROM table_from_query_testings")
assert_equal 1, columns.length
assert_equal "id", columns.first.name
ensure
@@ -514,11 +513,10 @@ class MigrationTest < ActiveRecord::TestCase
end
def test_create_table_with_query_from_relation
- Person.connection.create_table(:person, force: true)
-
- Person.connection.create_table :table_from_query_testings, as: Person.select(:id)
+ Person.connection.create_table :table_from_query_testings, as: Person.select(:id).where(id: 1)
columns = Person.connection.columns(:table_from_query_testings)
+ assert_equal [1], Person.connection.select_values("SELECT * FROM table_from_query_testings")
assert_equal 1, columns.length
assert_equal "id", columns.first.name
ensure