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/lib/active_record/connection_adapters/postgresql | |
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/lib/active_record/connection_adapters/postgresql')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb index 208934385f..ae7dbd2868 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb @@ -143,12 +143,6 @@ module ActiveRecord end end - def truncate_tables(*table_names) # :nodoc: - unless table_names.empty? - execute "TRUNCATE TABLE #{table_names.map(&method(:quote_table_name)).join(", ")}" - end - end - # Begins a transaction. def begin_db_transaction execute "BEGIN" @@ -170,6 +164,10 @@ module ActiveRecord end private + def build_truncate_statements(*table_names) + "TRUNCATE TABLE #{table_names.map(&method(:quote_table_name)).join(", ")}" + end + # Returns the current ID of a table's sequence. def last_insert_id_result(sequence_name) exec_query("SELECT currval(#{quote(sequence_name)})", "SQL") |