Class: BulkInsert::StatementAdapters::MySQLAdapter

Inherits:
BaseAdapter
  • Object
show all
Defined in:
lib/bulk_insert/statement_adapters/mysql_adapter.rb

Instance Method Summary collapse

Methods inherited from BaseAdapter

#initialize

Constructor Details

This class inherits a constructor from BulkInsert::StatementAdapters::BaseAdapter

Instance Method Details

#insert_ignore_statementObject



6
7
8
# File 'lib/bulk_insert/statement_adapters/mysql_adapter.rb', line 6

def insert_ignore_statement
  'IGNORE'
end

#on_conflict_statement(columns, _ignore, update_duplicates) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/bulk_insert/statement_adapters/mysql_adapter.rb', line 10

def on_conflict_statement(columns, _ignore, update_duplicates)
  return '' unless update_duplicates

  update_values = columns.map do |column|
    "`#{column.name}`=VALUES(`#{column.name}`)"
  end.join(', ')
  ' ON DUPLICATE KEY UPDATE ' + update_values
end

#primary_key_return_statement(_primary_key) ⇒ Object



19
20
21
# File 'lib/bulk_insert/statement_adapters/mysql_adapter.rb', line 19

def primary_key_return_statement(_primary_key)
  ''
end