Sha256: 1c3c85750f30546a88f6d5bba7dd4b342185645d957b6c58b92fce8930eeb4e1

Contents?: true

Size: 570 Bytes

Versions: 5

Compression:

Stored size: 570 Bytes

Contents

require_relative 'base_adapter'

module BulkInsert
  module StatementAdapters
    class MySQLAdapter < BaseAdapter
      def insert_ignore_statement
        'IGNORE'
      end

      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

      def primary_key_return_statement(_primary_key)
        ''
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
bulk_insert-1.9.0 lib/bulk_insert/statement_adapters/mysql_adapter.rb
bulk_insert-1.8.2 lib/bulk_insert/statement_adapters/mysql_adapter.rb
bulk_insert2-1.0.0 lib/bulk_insert/statement_adapters/mysql_adapter.rb
bulk_insert-1.8.1 lib/bulk_insert/statement_adapters/mysql_adapter.rb
bulk_insert-1.8.0 lib/bulk_insert/statement_adapters/mysql_adapter.rb