Class: ActiveRecordDataLoader::BulkInsertStrategy
- Inherits:
-
Object
- Object
- ActiveRecordDataLoader::BulkInsertStrategy
- Defined in:
- lib/active_record_data_loader/bulk_insert_strategy.rb
Instance Method Summary collapse
-
#initialize(data_generator, file_adapter) ⇒ BulkInsertStrategy
constructor
A new instance of BulkInsertStrategy.
- #load_batch(row_numbers, connection) ⇒ Object
- #name ⇒ Object
- #table_name ⇒ Object
Constructor Details
#initialize(data_generator, file_adapter) ⇒ BulkInsertStrategy
Returns a new instance of BulkInsertStrategy.
5 6 7 8 |
# File 'lib/active_record_data_loader/bulk_insert_strategy.rb', line 5 def initialize(data_generator, file_adapter) @data_generator = data_generator @file_adapter = file_adapter end |
Instance Method Details
#load_batch(row_numbers, connection) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/active_record_data_loader/bulk_insert_strategy.rb', line 10 def load_batch(row_numbers, connection) command = <<~SQL INSERT INTO #{quoted_table_name(connection)} (#{column_list(connection)}) VALUES #{values(row_numbers, connection)} SQL insert(connection: connection, command: command) file_adapter.insert(command) end |
#name ⇒ Object
23 24 25 |
# File 'lib/active_record_data_loader/bulk_insert_strategy.rb', line 23 def name "BULK INSERT" end |
#table_name ⇒ Object
19 20 21 |
# File 'lib/active_record_data_loader/bulk_insert_strategy.rb', line 19 def table_name data_generator.table end |