diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-17 06:06:21 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-17 09:37:08 +0900 |
commit | 0ad70eb2d063cab577a559f6c3d28e787ca1dca8 (patch) | |
tree | da8193ff9d12a38c826250a50fc98844bf0eb0e0 /activerecord/test | |
parent | 8ed636511779ed1472f4f88362ded34f61005f4a (diff) | |
download | rails-0ad70eb2d063cab577a559f6c3d28e787ca1dca8.tar.gz rails-0ad70eb2d063cab577a559f6c3d28e787ca1dca8.tar.bz2 rails-0ad70eb2d063cab577a559f6c3d28e787ca1dca8.zip |
Make `truncate_tables` to bulk statements
Before:
```
(16.4ms) TRUNCATE TABLE `author_addresses`
(20.5ms) TRUNCATE TABLE `authors`
(19.4ms) TRUNCATE TABLE `posts`
```
After:
```
Truncate Tables (19.5ms) TRUNCATE TABLE `author_addresses`;
TRUNCATE TABLE `authors`;
TRUNCATE TABLE `posts`
```
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapter_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/fixtures_test.rb | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index d25faf21d8..2b20d842e8 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -493,13 +493,13 @@ module ActiveRecord end def test_truncate_tables + assert_operator @connection.query_value("SELECT COUNT(*) FROM posts"), :>, 0 assert_operator @connection.query_value("SELECT COUNT(*) FROM authors"), :>, 0 assert_operator @connection.query_value("SELECT COUNT(*) FROM author_addresses"), :>, 0 - @connection.disable_referential_integrity do - @connection.truncate_tables("author_addresses", "authors") - end + @connection.truncate_tables("author_addresses", "authors", "posts") + assert_equal 0, @connection.query_value("SELECT COUNT(*) FROM posts") assert_equal 0, @connection.query_value("SELECT COUNT(*) FROM authors") assert_equal 0, @connection.query_value("SELECT COUNT(*) FROM author_addresses") end diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb index b4f28fbfd6..0c8263c9fd 100644 --- a/activerecord/test/cases/fixtures_test.rb +++ b/activerecord/test/cases/fixtures_test.rb @@ -209,7 +209,7 @@ class FixturesTest < ActiveRecord::TestCase conn = ActiveRecord::Base.connection mysql_margin = 2 packet_size = 1024 - bytes_needed_to_have_a_1024_bytes_fixture = 858 + bytes_needed_to_have_a_1024_bytes_fixture = 860 fixtures = { "traffic_lights" => [ { "location" => "US", "state" => ["NY"], "long_state" => ["a" * bytes_needed_to_have_a_1024_bytes_fixture] }, |